SSH2整合时struts路径导致的异常
今天在搭SSH2环境时,想当然地像struts1.x那样把struts.xml文件放在WEB-INF目录下,然后在web.xml中配置struts2时增加了param元素:
<!-- 配置Struts2 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts.xml</param-value>
</init-param>
</filter>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts.xml</param-value>
</init-param>
</filter>
结果 启动时报错:
com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=com.opensymphony.xwork2.ObjectFactory, name='default'] in public void com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.setObjectFactory(com.opensymphony.xwork2.ObjectFactory)
搜索很久没得到解决方法,于是把<init-param/>标签去掉,将struts.xml重新放回classpath下,再启动一切正常。
不知道是否能改变struts.xml的位置吗,是不是我的方法有问题