Struts2令牌 - 会话拦截器问题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Struts2令牌 - 会话拦截器问题相关的知识,希望对你有一定的参考价值。
我在我的业务Web应用程序中使用Struts 2,并且为了防止在刷新页面时双重输入,我在我的struts.xml文件中添加了拦截器
<interceptor-ref name="tokenSession"/>
当我将插入此语句时,它将始终重定向到invalid.token并转到tiles - requisition.tiles。我做错了什么?
如果我将删除上面的拦截器然后它将正常工作,那么问题是什么?
我在struts2.xml中的代码
<action name="*Requisition" class="com.sttl.rpsc.action.RequisitionAction" method="{1}Requisition">
<interceptor-ref name="basicStack" />
<interceptor-ref name="validation">
<param name="excludeMethods">setupRequisition,setupPostRequisition,setupQualificationRequisition,setUpForUpdateQualificationRequisition,
setupAgeRequisition,setupReservationRequisition,deletePostRequisition,showSaveCancelRequisition,setUpForUpdateAgeRequisition,setUpForUpdateReservationRequisition,
deleteQualificationRequisition,deleteAgeRequisition,deleteReservationRequisition,setScrutinizePostRequisition</param>
</interceptor-ref>
<interceptor-ref name="tokenSession"/>
<result name="invalid.token" type="tiles">/requisition.tiles</result>
<result name="input" type="tiles">/requisition.tiles</result>
<result name="success" type="tiles">/requisition.tiles</result>
<result name="error" type="tiles">/requisition.tiles</result>
<result name="cancel" type="redirect">rpscadminsecure.action</result>
<result name="getRequisitionList" type="chain">setupRequisition</result>
<result name="reqsuccess" type="chain">setupPostRequisition</result>
<result name="postsuccess" type="tiles">/requisitionpost.tiles</result>
<result name="qualisuccess" type="tiles">/requisitionqualification.tiles</result>
<result name="agesuccess" type="tiles">/requisitionage.tiles</result>
<result name="ressuccess" type="tiles">/requisitionreservation.tiles</result>
<result name="saveOrCancelsuccess" type="tiles">/saveOrCancelrequisition.tiles</result>
<result name="cancelSuccess" type="redirect">setupRequisition</result>
<result name="successSetupScrutinize" type="tiles">/requisitionpost.tiles</result>
</action>
答案
您必须更改拦截器中声明的顺序。像这样的东西:
<action name="someAction" class="com.examples.SomeAction">
<interceptor-ref name="token-session/>
<interceptor-ref name="basicStack"/>
<result name="success">good_result.ftl</result>
</action>
basicStack是订单中的最后一个。
以上是关于Struts2令牌 - 会话拦截器问题的主要内容,如果未能解决你的问题,请参考以下文章
OkHttpInterceptor 从 kotlin 拦截器导航到登录片段