如果我添加"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
类来避免它。如果是这样怎么做?
答案 0 :(得分:0)
仅当ActionContext
包含参数token
时,才会显示此警告。在execAndWait
拦截器之前删除此参数。
ActionContext.getContext().getParameters().remove("token");
BTW,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>