@RunWith(SpringJUnit4ClassRunner.class ) @ContextConfiguration(locations ={ "/applicationContext.xml","/spring/*.xml"} ) public class CustomersActionTestCase extends StrutsSpringTestCase { @Test public void testLoginAction(){ // 1、 this.request.setParameter("customer.email", "abc@163.com"); this.request.setParameter("customer.passWord", "123456"); try { String result = executeAction("/doCustomers_login"); System.out.println(result); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ServletException e) { e.printStackTrace(); } // 2、 // ActionProxy actionProxy = this.getActionProxy("/doCustomers_login?customer.email=abc@163.com&customer.passWord=123456"); // Assert.assertNotNull(actionProxy); } } 上面的运行就出错: java.lang.NoClassDefFoundError: javax/servlet/jsp/PageContext at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) ... Caused by: java.lang.ClassNotFoundException: javax.servlet.jsp.PageContext at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) ... 38 more serlvet-api.jar有了。 这个问题出在哪里? |
|
10分 |
缺少:
jsp-api.jar |
30分 |
1.缺jsp的jar包
2。getActionProxy你可以理解为一个测试方法,在后台模拟调用action |
@RunWith(SpringJUnit4ClassRunner.class ) @ContextConfiguration (locations ={ "/applicationContext.xml","/spring/*.xml"} ) public class CustomersActionTestCase extends StrutsSpringJUnit4TestCase<CustomersAction> { .......... } 这里的StrutsSpringJUnit4TestCase 与StrutsSpringTestCase 什么关系? |