初始代码:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts> <package name="default" namespace="/" extends="struts-default"> <action name="login_*" class="action.LoginAction" method="{1}">
<result name="success">/success.jsp</result>
<result name="input">/login.jsp</result>
<result name="{1}">/test1.jsp</result>
</action> <default-action-ref name="error"></default-action-ref> <action name="error">
<result>/error.jsp</result>
</action>
</package>
</struts>
报错,后查阅资料
原因 action与result-type顺序搞错了
package里元素必须按照一定的顺序排列:
result-types
interceptors
default-interceptor-ref
default-action-ref
default-class-ref
global-results
global-exception-mappings
action*
修改后代码
<struts>
<package name="default" namespace="/" extends="struts-default">
<default-action-ref name="error"></default-action-ref>
<action name="error">
<result>/error.jsp</result>
</action> <action name="login_*" class="action.LoginAction" method="{1}">
<result name="success">/success.jsp</result>
<result name="input">/login.jsp</result>
<result name="{1}">/test1.jsp</result>
</action>
</package>
</struts>
就搞定了