1

如果我添加"execAndWait"拦截器,它会给我上面的错误:

TokenHelper - Could not find token mapped to token name struts.token

配置:

<action name="flightsearch" method="getFlightResult"
    class="com.test.FlightSearchAction">
    
    <interceptor-ref name="execAndWait">
        <param name="delay">500</param>
        <param name="delaySleepInterval">500</param>
    </interceptor-ref>
    <!--  <interceptor-ref name="token">
        <param name="excludeMethods">getFlightResult</param>
    </interceptor-ref> -->
    <result name="wait" type="tiles">flightwait</result>
    <result name="success" type="tiles">flightsearchresult</result>
</action>

<interceptors>
    <interceptor-stack name="tokenCheck">
        <interceptor-ref name="token" />
        <interceptor-ref name="defaultStack" />
        <interceptor-ref name="basicStackHibernate" />
    </interceptor-stack>
    
    <interceptor-stack name="loggingRequired">
        <interceptor-ref name="defaultStack" />
        <interceptor-ref name="basicStackHibernate" />
    </interceptor-stack>
    
</interceptors>

正如我所读到的,有人说这是一个警告,我们可以通过更改TokenHelper课程来避免它。如果是这样怎么做?

4

1 回答 1

0

ActionContext仅当包含参数时才会出现此警告tokenexecAndWait在拦截器之前去掉这个参数。

ActionContext.getContext().getParameters().remove("token");

顺便说一句,execAndWait拦截器应该在completeStack. 例如

<action name="someAction" class="com.examples.SomeAction">
    <interceptor-ref name="completeStack"/>
    <interceptor-ref name="execAndWait"/>
    <result name="wait">wait.jsp</result>
    <result name="success">success.jsp</result>
</action>
于 2013-09-15T09:34:42.690 回答