案例目录
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
求解?谢谢!!!。。。。
你的女友漏气了
慕的地6079101
younghu
熊猫程序员
相关分类