ITeye博客

Struts2 Dispatcher initialization failed No mapping found for dependency default

chainhou · 2013-04-10 16:41 · 常见问题 · 开源软件 · Markdown

在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项指定了需要的文件。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。