webwork 防止页面重复提交(增,删改)

看一下怎么实际运用(In Action):

1.定义你自己的拦截器栈:
   <interceptors>   
    <interceptor-stack name="submitToken">
     <interceptor-ref name="token-session"/>
     <interceptor-ref name="defaultStack"/> 
    </interceptor-stack>
   </interceptors>


2.在需要防止重复提交的action里添加刚刚定义的拦截器栈,像这样:
 
 <action name="sendMessage" class="net.jbbs.webwork.MessageAction" method="send">
    <result name="success" type="dispatcher">
     <param name="location">getMessagesList.action?type=sendbox</param>
    </result>
    <result name="fail" type="dispatcher">
     <param name="location">sendMessage.jsp</param>
    </result>
    <result name="invalid.token" type="dispatcher">
     <param name="location">sendMessage.jsp</param>
    </result>
    <interceptor-ref name="submitToken"/>
   </action>

3.修改相应的包含提交表单的jsp文件,在这里是sendMessage.jsp:
     <ww:token name="sendMessageToken"/>

做完上面三个步骤,应该可以实现防止重复提交了

你可能感兴趣的:(java,jsp,Webwork)