1.加入<s:token>标签
在<s:form ...></s:form>中加入
<s:token></s:token>
或
<s:token name="hello"></s:token>
将会生成
<input type="hidden" name="struts.token.name" value="hello">
<input type="hidden" name="hello" value="DBFIPUA0IFVGS9..." />
2.加入拦截器
在struts.xml中的action中加入token拦截器
<interceptor-ref name="token"></interceptor>
<interceptor-ref name="defaultStack"></interceptor>
3.配置 结果页面
在struts.xml的action中加入result,name为invalid.token
<result name="invalid.token">/registor.jsp</result>
4.显示出错信息
<s:actionerror cssStyle="color:red"/>
5.修改默认的出错信息
默认信息在struts-messages.properties中
struts.messages.invalid.token="The form ..."
在自定义的message_zh_CN.properties中替换
struts.messages.invalid.token=请不要重复提交表单