走一下action流程再到要防止重复提交的页面
public class PrepareTokenAction extends Action {
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
// Generate a unique token that will be
// check when the form is submitted
saveToken(request);
// Forward to the form
return mapping.findForward("success");
}
}
处理提交页面的action
public class ProcessTokenAction extends Action {
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
// If user pressed 'Cancel' button,
// return to home page
if (isCancelled(request)) {
return mapping.findForward("home");
}
ActionErrors errors = new ActionErrors();
// Prevent unintentional duplication submissions by checking
// that we have not received this token previously
if (!isTokenValid(request)) {
errors.add(
ActionMessages.GLOBAL_MESSAGE,
new ActionMessage("errors.token"));
}
resetToken(request);
// Report any errors we have discovered back to the original form
if (!errors.isEmpty()) {
saveErrors(request, errors);
saveToken(request);
return (mapping.getInputForward());
}
// Forward to result page
return mapping.findForward("success");
}
}
分享到:
相关推荐
Struts1.x常用的开发包,需要学习struts1.x朋友可以下载
struts1.x和struts2.x区别
Struts 2.x权威指南(第3版)
freemarker与struts 1.x 结合,生成html 在http://blog.csdn.net/chen1255 的web中有详细描述关于freemarker与struts1.x的结合
在这里,通过一个小例子稍微总结了下struts1和struts2的区别,希望这个能帮助到初学struts的朋友
java Struts 1.x 框架 Web 开发 java Struts 1.x 框架 Web 开发
Struts1.x的登录示例,Struts1.x相关详细教程参考我的Blog:http://blog.csdn.net/boyazuo
struts1.x apps 所有最新的Struts1.x项目应用 struts1.x apps 所有最新的Struts1.x项目应用 欢迎大家下载。。。
Struts1.x实现防止提交的Token使用示例。工程环境:MyEclipse
struts1.x入门教程
struts1.x多文件上传, 感觉不错.
struts1 国际化 源代码 struts1 国际化 工程
struts2防止表单重复提交,利用struts的拦截器tokenSession,轻轻松松解决表单重复提交的问题。 附件为源代码,后台延迟了3秒,可直接在web服务器下部署运行,输入用户名和密码后,多点几次提交按钮,然后看控制台...
适用于Struts1.x初学者(网摘共25节)
这是struts1.x标签! struts1.x是历经考验的成熟的框架! 此标签可以帮助你更好的学习struts1.x的标签!
Struts1.x-Jdbc,学习Struts1.的曾删改查
struts1.x和mysql整合的登陆例子,包括用户的增删改查,涉及到LookupDispatchAction,的多个submit提交,静态验证,和读取数据库properties文件
基于Struts1.x的简单电子商务系统,hiberntae实现数据的持久化,数据库是Mysql
struts1.x 学习总结 struts1.x 学习总结 struts1.x 学习总结 struts1.x 学习总结