实战Struts1.2防重复提交

1.to方法

public ActionForward toSingle(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { this.saveToken(request); return mapping.findForward("single"); }

 

2.页面

<input type="hidden" name="org.apache.struts.taglib.html.TOKEN" value= "<%=session.getAttribute("org.apache.struts.action.TOKEN")%>"/>

 

 

3.处理方法

public ActionForward single(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){ if (!this.isTokenValid(request)) { //防重复提交 this.saveToken(request); info = "对不起,您不能重复提交!"; }else{ this.resetToken(request); } }

你可能感兴趣的:(exception,struts,input)