Struts2 Dispatcher initialization failed No mapping found for dependency default

在struts2的使用时如果发现以下异常信息,
严重: Dispatcher initialization failed
com.opensymphony.xwork2.inject.DependencyException: 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).


可能原因是:你在web.xml中重新指定了struts.xml的位置,导致struts.xml需要使用的struts-default.xml无法找到。
解决方式是在web.xml中也添加struts-default.xml,如下:
 <filter>
		<filter-name>struts2</filter-name>
		<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
		<init-param>
			<param-name>config</param-name>
			<param-value>struts-default.xml,struts-plugin.xml,struts.xml</param-value>
		</init-param>
	</filter>


param-value项指定了需要的文件。

猜你喜欢

转载自chainhou.iteye.com/blog/1845210
今日推荐