Struts1.2下测试action时不能加载spring配置文件
使用strutstest214-1.2_2.4测试Struts1.2的action时,提示java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?,我在web.xml中已经添加了如下配置:
<context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener>
@Test public void testUnspecified() { setContextDirectory(new File("WebRoot")); setRequestPathInfo("/loginAction"); try { addRequestParameter("loginName", "001"); addRequestParameter("passWd", "001"); actionPerform(); } catch (Exception e) { e.printStackTrace(); } }