首次整合struts2+spring 提交表单后报的500错误

spring+struts2整合,做了一个用户登陆的测试程序,附下配置文件片段 
 <constant name="struts.objectFactory" value="spring"/>
 
 <package name="struts-config" namespace="/" extends="struts-default">
 
  <action name="login" class="loginAction">
   <result name="frame">/frame.jsp </result>
  </action>
 </package>
</struts> 
但提交表单后报的如下500错误,如果直接写class="com.system.actionLoginAction"可以执行

Unable to instantiate Action, loginAction,  defined for 'login' in namespace '/'loginAction 
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:306) 
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:387) 
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:186) 
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61) 
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39) 
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47) 
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:458) 
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) 
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:76)

 

从错误看是spring没能给struts2创建出action,可能出现的原因:

1.没有加载struts2-spring-plugin-2.1.8.1.jar

2.包冲突,删除asm.jar(网上说的)

3.struts或spring 配置文件错误(可以看我写的“struts2+spring整合框架 ”)

4.spring配置文件名错误,spring配置文件默认是applicationContext.xml,在web.xml中可能会配成

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value>
 </context-param> 


你可能感兴趣的:(spring,struts2,整合)