SpringMVC JSP解决表单重复提交问题
2014年1月10日
没有评论
web应用在用户表单操作的时候由于连续点击或者界面提交完刷新等情况,会出现重复提交的问题。下面给出其中一种解决方案:利用session和表单的token值做对比,如果不相等则表示重复提交。
1.自定义标签
<?xml version="1.0" encoding="UTF-8"?> <taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" version="2.0"> <description>viway view tag lib</description> <tlib-version>3.0</tlib-version> <short-name>viway</short-name> <uri>http://www.viway.com/tag/view</uri> <tag> <name>token</name> <tag-class>com.viway.project.jsp.tag.TokenTag</tag-class> <body-content>empty</body-content> <attribute> <name>token</name> <required>false</required> </attribute> </tag> </taglib>
2.token class 阅读全文…