开发者

Struts2 token-Session interceptor problem

开发者 https://www.devze.com 2023-02-22 13:33 出处:网络
I\'m using Struts 2 in my business web application, and to prevent double entry at the time of refresh page I had add interceptor in my struts.xml file in action

I'm using Struts 2 in my business web application, and to prevent double entry at the time of refresh page I had add interceptor in my struts.xml file in action

<interceptor-ref name="tokenSession"/>

When I will insert this stateme开发者_运维技巧nt, it will always redirect to invalid.token and goes to tiles - requisition.tiles. What is the mistake I've done?

And if I will remove above interceptor then it will work fine, so what's the problem?

My code in 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>


You have to change the order of the declaration in the interceptors. Something like this:

<action name="someAction" class="com.examples.SomeAction">
<interceptor-ref name="token-session/>
<interceptor-ref name="basicStack"/>
<result name="success">good_result.ftl</result>
</action>  

The basicStack is the last in the order.

0

精彩评论

暂无评论...
验证码 换一张
取 消