<s:token/>struts2标签 拦截器 (1)

来源:互联网 发布:华为手机支持4g网络吗 编辑:程序博客网 时间:2024/05/16 05:03
转自:http://www.cnblogs.com/guanghuiqq/archive/2012/08/10/2632323.html
<s:token />标签防止重复提交,用法如下:
第一步:在表单中加入<s:token />
<s:form action="helloworld_other" method="post" namespace="/test">
<s:textfield name="person.name"/><s:token/><s:submit/>
</s:form>
第二步:
<action name="helloworld_*" class=“com.ambow.action.HelloWorldAction" method="{1}">
<interceptor-ref name="defaultStack" />
<interceptor-ref name="token" />
<result name="invalid.token">/WEB-INF/page/message.jsp</result>
<result>/WEB-INF/page/result.jsp</result>
</action>
以上配置加入了token拦截器和invalid.token结果,因为token拦截器在会话的token与请求的token不一致时,将会直接返回invalid.token结果。
 
debug状态,控制台出现下面信息,是因为Action中并没有struts.tokenstruts.token.name属性,我们不用关心这个错误:
严重: ParametersInterceptor - [setParameters]: Unexpected Exception caught setting 'struts.token' on 'class xxx: Error setting expression 'struts.token' with value '[Ljava.lang.String;@39f16f'
严重: ParametersInterceptor - [setParameters]: Unexpected Exception caught setting 'struts.token.name'

0 0
原创粉丝点击