美文网首页
Unable to load configuration. -

Unable to load configuration. -

作者: pure_joy | 来源:发表于2018-06-26 12:53 被阅读8次

一、

原因是缺少jar包:struts2-spring-plugin-2.1.8.jar

原先所struts创建的action类,交给了spring创建。在struts2-spring-plugin.jar中有一个struts-plugin.xml,里面声明了action类由spring工厂创建。在struts2插件文档里,这样写着“The Spring Plugin works by overriding the Struts ObjectFactory to enhance the creation of core framework objects。”这个插件重写了struts的对象工厂,当创建一个action类时,它会根据struts的配置文件的class属性的值与spring配置文件中的id属性的值相匹配。如果没有与之相匹配,将会像没有使用这个插件前一样创建,然后由spring自动装配。

二、

在web.xml中配置

<init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/classes/struts.xml,struts-default.xml,struts-plugin.xml</param-value>  
</init-param>
注意:不推荐这种解决方式,因为在调用action处理的时候会报

There is no Action mapped for namespace / and action name的错误

相关文章

网友评论

      本文标题:Unable to load configuration. -

      本文链接:https://www.haomeiwen.com/subject/wtnpyftx.html