我们知道ActionClassName-validation.xml是在ActionClassName.java之前执行的。
现在我有一个在ActionClassName.java之前执行的拦截器。
执行顺序是:
我的问题是:是否可以订购以下订单?
在我的struts.xml中,我有以下配置:
<interceptor class="com.myproject.user.interceptor.PermissionInterceptor" name="PermissionInterceptor"></interceptor>
<interceptor-stack name="permissionStack">
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="PermissionInterceptor" />
</interceptor-stack>
<action name="addCommentAction" class="com.myproject.action.AddCommentAction">
<interceptor-ref name="permissionStack" />
<result name="success">homePage.jsp</result>
<result name="error">homePage.jsp</result>
<result name="login">login.jsp</result>
<result name="input">addComment.jsp</result>
</action>
提前致谢, 纳比勒埃拉拉
答案 0 :(得分:0)
在struts.xml
<package name="mydefault" namespace="/" extends="struts-default">
<interceptors>
<interceptor name="yourInterceptor" class="YourPackage.YourInterceptorClass"></interceptor>
<interceptor-stack name="myStack">
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="paramsPrepareParamsStack" />
<interceptor-ref name="yourInterceptor" />
<interceptor-ref name="validationWorkflowStack" />
.... Other interceptors
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="myStack"/>
...Other actions
</package>
您可以更改订单。
有关更详细的订单,请参阅Interceptor Documentation
defaultStack
拦截器列表如下所示。
<interceptor-stack name="defaultStack">
<interceptor-ref name="exception"/>
<interceptor-ref name="alias"/>
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="i18n"/>
<interceptor-ref name="chain"/>
<interceptor-ref name="debugging"/>
<interceptor-ref name="profiling"/>
<interceptor-ref name="scopedModelDriven"/>
<interceptor-ref name="modelDriven"/>
<interceptor-ref name="fileUpload"/>
<interceptor-ref name="checkbox"/>
<interceptor-ref name="staticParams"/>
<interceptor-ref name="actionMappingParams"/>
<interceptor-ref name="params">
<param name="excludeParams">dojo\.. * , ^ struts \ .. *</param>
</interceptor-ref>
<interceptor-ref name="conversionError"/>
<interceptor-ref name="validation">
<param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
<interceptor-ref name="workflow">
<param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
</interceptor-stack>
您可以通过更改顺序将它们放在struts.xml
中,如下所示。
<package name="mydefault" namespace="/" extends="struts-default">
<interceptors>
<interceptor name="yourInterceptor" class="YourPackage.YourInterceptorClass"></interceptor>
<interceptor-stack name="myStack">
<interceptor-ref name="exception"/>
<interceptor-ref name="alias"/>
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="i18n"/>
<interceptor-ref name="chain"/>
<interceptor-ref name="debugging"/>
<interceptor-ref name="profiling"/>
<interceptor-ref name="scopedModelDriven"/>
<interceptor-ref name="modelDriven"/>
<interceptor-ref name="fileUpload"/>
<interceptor-ref name="checkbox"/>
<interceptor-ref name="staticParams"/>
<interceptor-ref name="actionMappingParams"/>
<interceptor-ref name="params">
<param name="excludeParams">dojo\..*,^struts\..*</param>
</interceptor-ref>
<interceptor-ref name="conversionError"/>
/*putting your interceptor in between or any order */
<interceptor-ref name="yourInterceptor" />
<interceptor-ref name="validation">
<param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
<interceptor-ref name="workflow">
<param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
<interceptor-ref name="paramsPrepareParamsStack" />
<interceptor-ref name="validationWorkflowStack" />
.... Other interceptors
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="myStack"/>
...Other actions
</package>