我一直试图让tokenSession拦截器工作(Struts 2.0.14),但总是得到警告:
2013-03-13 08:32:09,395 [17] DEBUG Intercepting invocation to check for valid transaction token. | org.apache.struts2.interceptor.TokenSessionStoreInterceptor.doIntercept(128)
2013-03-13 08:32:09,395 [17] WARN Could not find token name in params. | org.apache.struts2.util.TokenHelper.getTokenName(124)
2013-03-13 08:32:09,396 [17] DEBUG no token name found -> Invalid token | org.apache.struts2.util.TokenHelper.validToken(154)
2013-03-13 08:32:09,397 [17] WARN Could not find token name in params. | org.apache.struts2.util.TokenHelper.getTokenName(124)
2013-03-13 08:32:09,397 [17] WARN Could not find token mapped to token name null | org.apache.struts2.util.TokenHelper.getToken(105)
2013-03-13 08:32:09,398 [17] DEBUG Forwarding to location /WEB-INF/view/support/TokenError.jsp | org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(113)
struts.xml具有以下拦截器配置:
<package name="survey" extends="struts-default">
<result-types>
<result-type name="csv"
class="webapp.CsvResultType"/>
</result-types>
<interceptors>
<interceptor name="log"
class="struts.LoggingInterceptor"/>
<interceptor name="formAuthentication"
class="security.FormAuthenticationInterceptor"/>
<interceptor-stack name="default">
<interceptor-ref name="log"/>
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="formAuthentication"/>
<!--interceptor-ref name="chain"/>-->
<interceptor-ref name="fileUpload"/>
<interceptor-ref name="checkbox"/>
<interceptor-ref name="params"/>
</interceptor-stack>
<interceptor-stack name="defaultTokenStack">
<interceptor-ref name="tokenSession"/>
<interceptor-ref name="default"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="default"/>
<!-- -->
<global-results>
<result name="blank">/WEB-INF/view/support/Blank.jsp</result>
<result name="error">/WEB-INF/view/support/Error.jsp</result>
<result name="insufficientPrivileges">/WEB-INF/view/support/InsufficientPrivileges.jsp</result>
<!--result name="file" type="file"></result-->
</global-results>
</package>
使用操作定义:
<package name="respondent" namespace="/respondent" extends="survey">
<action name="*" class="controller.respondent.{1}Action">
<interceptor-ref name="defaultTokenStack"/>
<result name="list">/WEB-INF/view/respondent/{1}List.jsp</result>
<result name="edit">/WEB-INF/view/respondent/{1}Edit.jsp</result>
<result name="view">/WEB-INF/view/respondent/{1}View.jsp</result>
<result name="success">/WEB-INF/view/respondent/{1}.jsp</result>
<result name="invalid.token">/WEB-INF/view/support/TokenError.jsp</result>
</action>
</package>
jsp有令牌标记:
<s:form action="FunctionSummary.action" method="post">
<s:token/>
<table class="buttons">
<tr>
<s:if test="surveyStarted">
<td><s:submit value="Resume Survey"/></td>
</s:if>
<s:else>
<td><s:submit value="Start Survey"/></td>
</s:else>
</tr>
</table>
</s:form>
对此页面的任何访问都会导致重定向到invalid.token结果和上面的警告。
我已经验证过,如果没有配置拦截器,页面源会有令牌但我无法让sessionToken拦截器看到它。
任何帮助都会非常感激......
由于
答案 0 :(得分:1)
尝试将<s:token/>
标记放入<table>
标记中。
我和你一样有同样的问题。在我将<s:token/>
放入<table>
标记后,问题就解决了。
<s:form action="" id = "" theme="simple" method = "post">
<table id = "" border="1" width="200">
<s:token/> <!-- In the table tag -->
</table>
</s:form>