当前位置: 代码迷 >> J2EE >> 关于struts2与spring整合的一个有关问题(出现Error filterStart)
  详细解决方案

关于struts2与spring整合的一个有关问题(出现Error filterStart)

热度:10   发布时间:2016-04-22 01:43:49.0
关于struts2与spring整合的一个问题(出现Error filterStart)
启动Tomcat时出现Error   filterStart的错误,我的struts.xml如下:
<struts>
          <constant   name= "objectFactory "   value= "spring "> </constant>
          <package   name= "myssh "   namespace= "/ "   extends= "struts-default ">
                <action   name= "login "   class= "LoginAction ">
                        <result   name= "success ">
                                welcome.jsp
                        </result>              
        </package>
</struts>
其中 <constant   name= "objectFactory "   value= "spring "> </constant> ,是我在网上查的,说是要将struts2与spring整合,应填写这句话,还有一种说法是struts2应该和webwork一样,就是建立一个struts.properties文件,在里边填写struts.objectFactory=spring,但我试了也出现Error   filterStart。
applicationContext.xml中与struts.xml对应的是
...
<bean   id= "LoginAction "   class= "my.ssh.action.LoginAction ">
</bean>
...

我在网上查的说在加载filter时,必须能够找到对应的class,就是 <action   name= "login "   class= "LoginAction "> 中的LoginAction,出现Error  
filterStart可能是路径名不全,我改为class= "my.ssh.action.LoginAction "后确实没有出现Error   filterStart,但这样不就没用上spring了吗,请高手赐教

------解决方案--------------------
struts.objectFactory=spring
<constant name= "objectFactory " value= "spring "> </constant>
不用写的,我现在就用的是SPRING+STURTS2.08+HIBERNATE,就没有写那写东西,运行正常,写了估计就不正常了
------解决方案--------------------
filterStart的问题是web.xml的问题,不关struts2的问题,你看下tomcat/logs/下的文件,可以找到线索的。
------解决方案--------------------
楼上说的没错 
filterStart的问题是tomcat启动时加载web.xml配置文件引起的问题,如果你在web.xml配置加载spring
那么请检查spring配置文件是否有误,可以将配置文件的内容部分注释掉,从而查找具体是某个配置问题导致的
当然出现这个问题,也有可能是jar包冲突引起的

------解决方案--------------------
必须添加
struts2-spring-plugin

------解决方案--------------------
一般是由于缺包导致的,务必将struts2-spring-plugin包导入到CLASSPATH下。
------解决方案--------------------
stefli 和 shareanway 兄弟说的很正确,是由于加载的jar包不完整引起的错误
 鄙视yuanzhicai说的话,别人是来求教的,不是来让你数落的,如果你知道原因请告知后再批评
csdn就是被这种人带坏的。。。
------解决方案--------------------
这个问题让我郁闷了好长时间。十分感谢楼主和各位给出答案的大牛们^_^
  相关解决方案