页面访问404错误
tomcat启动报错:
原因:查看lib下的jar包发现 有struts2-spring-plugin-2.3.24.1.jar
表明该插件引入工程后,会自动设置Struts的ObjectFactory为StrutsSpringObjectFactory,从而让Spring的IOC容器来托管Struts的Action。所以导致了启动的问题。
但是工程web.xml中没有配置加载spring ApplicationContext相关的listener
- <listener>
- <listener-class>
- org.springframework.web.context.ContextLoaderListener
- </listener-class>
- </listener>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
解决方法:
1. 删除struts2-spring-plugin-2.3.24.1.jar
2.在web.xml中添加spring监听,配置struts2 .xml 可以不配置因为默认值为struts.objectFactory = spring
<constant name="struts.objectFactory" value="spring" />
-
顶
- 0
-
踩
- 0