为了账号安全,请及时绑定邮箱和手机立即绑定

程序员小白的提问 +__+、:struts+spring配置问题

程序员小白的提问 +__+、:struts+spring配置问题

熊猫程序员 2017-03-30 12:20:27
案例目录spring.xml配置<!-- dispartchAction配置 --><bean id="dispartchAction" class="sshDemo1.action.DispatchAction"scope="prototype"></bean><!-- userAction配置 --><bean id="userAction" class="sshDemo1.action.UserAction"scope="prototype"></bean>struts配置<struts> <constant name="struts.i18n.encoding" value="UTF-8"></constant> <constant name="struts.action.extension" value="html"></constant> <constant name="struts.enable.DynamicMethodInvocation" value="false"></constant> <package name="packageDemo1" extends="struts-default" namespace="/"> <!-- 注意:在struts2.3以后使用通配符配置需要将struts.enable.DynamicMethodInvocation=false          同时,在package下配置global-allowed-methods或配置在action下配置allowed-methods   -->  <global-allowed-methods>login,index</global-allowed-methods>  <action name="dispartchAction_*" class="dispartchAction" method="{1}">   <result name="index">/WEB-INF/index.jsp</result>   <result name="login">/WEB-INF/login.jsp</result>  </action>  <action name="userAction_*" class="userAction" method="{1}">   <result name="success">/WEB-INF/success.jsp</result>   <result name="login">/WEB-INF/login.jsp</result>  </action> </package></struts>web.xml配置  <context-param>   <param-name>contextConfigLocation</param-name>   <param-value>classpath:spring.xml</param-value>  </context-param>  <listener>   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  </listener>  <filter>   <filter-name>struts2</filter-name>   <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>  </filter>  <filter-mapping>   <filter-name>struts2</filter-name>   <url-pattern>/*</url-pattern>  </filter-mapping>index.jsp页面<a href="${pageContext.request.contextPath}/dispartchAction_login.html">登录</a>login.jsp页面 <form action="${pageContext.request.contextPath}/userAction_login.html" method="post">当访问index.jsp和在index.jsp跳转到login.jsp的时候,程序没有错误,但是当登录访问userAction的时候报错,说找不到userAction对象。HTTP Status 500 - Unable to instantiate Action, userAction, defined for 'userAction_login' in namespace '/'Cannot find class [sshDemo1.action.UserAction] for bean with name 'userAction' defined in class path resource [spring.xml]; nested exception is java.lang.ClassNotFoundException: sshDemo1.action.UserAction求解?谢谢!!!。。。。
查看完整描述

3 回答

已采纳
?
你的女友漏气了

TA贡献3条经验 获得超0个赞

错误信息写的清清楚楚啊

查看完整回答
反对 回复 2017-03-31
  • 熊猫程序员
    熊猫程序员
    我看那错误应该是找不到userAction这个类对象,但是我在spring.xml中配置了这个类 <!-- userAction配置 --> <bean id="userAction" class="sshDemo1.action.UserAction" scope="prototype"></bean> 我访问dispartchAction的时候可以访问,也就说明加载到了配置文件spring,但是当点击登陆,表单提交找userAction的时候就报错,我就感觉和差异,我觉得是spring.xml文件没有创建到这个对象,所以报错。但是为什么前面的能够找到dispathAction,后面userAction的找不到。
?
younghu

TA贡献25条经验 获得超6个赞

你form表单action 写错了吧。不是xx.action吗
查看完整回答
反对 回复 2017-04-01
?
熊猫程序员

TA贡献7条经验 获得超0个赞

我刚刚认真看了一遍,将改了一下dispartchAction-->dispatchAction然后将服务器clear了一下,然后从新启动了一下,就可以了#_#,具体情况我觉得可能是服务器缓存了数据没有更新,但是昨天确实是重启服务器了,就是不行。哎~,真心累,。。。。。。。。

查看完整回答
反对 回复 2017-03-31
  • 3 回答
  • 0 关注
  • 2172 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信