码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2015-10-21 15:59:28      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:struts2   spring   整合   

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> 


本文出自 “没有水勒鱼” 博客,请务必保留此出处http://javaqun.blog.51cto.com/10687700/1704867

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

标签:struts2   spring   整合   

原文地址:http://javaqun.blog.51cto.com/10687700/1704867

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!