Struts2中struts.xml文件配置Interceptor的注意事项之顺序

最近在学习Struts2中interceptor的时候配置的囧事,
写了一个简单的loginInterceptor去尝试用interceptor做login,
写完配置完struts2.xml如下
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
 <struts>
    <package name="struts2" extends="struts-default">


    
    <global-results>
    	<result name="login" type="redirect">/userLogin.jsp</result>
    </global-results>
   
    <action name="saveUser" class="saveUserAction">
    <result name="success" type="redirect">listUser.action</result>
    <result name="input">/saveUser.jsp</result>
    </action>
   
    <action name="listUser" class="listUserAction">
    	<result name="success">/listUser.jsp</result>
    	<interceptor-ref name="defaultStack"></interceptor-ref>
    	<interceptor-ref name="myStack"></interceptor-ref>
    </action>
    
    <action name="userLogin" class="loginUserAction">
    	<result name="success">loginOK.jsp</result>
    	<result name="input">userLogin.jsp</result>
    </action>
 	
 	 <interceptors>
    	<interceptor name="loginInterceptor" class="com.test.interceptor.LoginInterceptor" ></interceptor>
    </interceptors>
 	
    </package>
 </struts>

结果无辜的报了The content of element type "package" must match "(result-types?,interceptors?,default-interc错误,囧了,都有了啊格式也没问题啊。搞了半天,struts.xml中的配置不光要东西齐全,还要 按顺序来,先interceptor,再什么什么,最后才是action的配置。把interceptors的tag移动到上面,一切OK

你可能感兴趣的:(apache,xml,jsp,struts)