The present invention relates to the technical field of computer application, in particular relates to a method for preventing repeated page submissions, modifying the traditional Token token mechanism, according to the group assignment of token objects, each object token 1 URL requests, all token objects form a token object, then through the token signal from the cumulative compared with 1, when judging whether the repeated submission of first removed the token group corresponding to the page on the server, and then each group object for the current request and the judgment whether the token object with 1 signals, if greater than 1 for repeated submission, termination of operation returns an error message; no, the execution of business procedure the test is finished; the invention generates a token by form, will not be modified, at the same time a token corresponds to a control request, submitted repeatedly is the entire page, The unrestricted number of token groups can be stored, and the method is simple and efficient, which can effectively prevent the repeated submission of the page.
【技术实现步骤摘要】
一种防止页面重复提交的方法
本专利技术涉及计算机应用
,具体的讲涉及一种防止页面重复提交的方法。
技术介绍
现有技术方案中采用了Token(令牌)机制,原理如下:当访问一个请求的时候,底层框架将一个令牌(所谓令牌就是一个随机生成的一个字符串)放入会话中存储起来,然后再转向到页面,页面中html:form标签将会话中的令牌保存到form表单中一个隐藏的input域中,等用户输入完数据,然后点击保存执行保存请求的时候,底层框架会在业务程序之前判断会话中的令牌和客户端传递过来的隐藏input域中的令牌是否相等,如果相等,则更新会话中的令牌,并去执行业务程序;当系统反应速度比较慢,用户可能会点击第二次或者用户点击浏览器的回退,然后再点击提交,或者直接刷新页面,提交执行,在上面这几种情况下,由于点击第一次后,会话中的令牌已经更新,因此会话中的令牌和隐藏input域中的令牌就不相等,则是重复提交,返回一个错误页面提示重复提交。因此这种方案造成的不足是:1、一个html中如果有多个form表单,而且需要同时提交时,第二个要提交的form将不能提交,因为当提交了第一个for ...
【技术保护点】
一种防止页面重复提交的方法,其特征在于:修改传统的Token令牌机制,采用按组分配的token对象,每个所述token对象对应1个url请求,所有token对象构成一个token对象组,然后通过token的信号量命中累计,与1进行对比,具体步骤如下:1)在html各个form需要的位置,产生一个唯一的token,每个页面由多个form的token构成一个组;2)在提交时,前端将token和token组传递给后台,后台通过组中存放的每个form的组进行命中存放;3)比对后每个token对应一个令牌,并将令牌放入当前页面对应的这个令牌组中;4)后端判断重复提交的时候,首先取出对 ...
【技术特征摘要】
1.一种防止页面重复提交的方法,其特征在于:修改传统的Token令牌机制,采用按组分配的token对象,每个所述token对象对应1个url请求,所有token对象构成一个token对象组,然后通过token的信号量命中累计,与1进行对比,具体步骤如下:1)在html各个form需要的位置,产生一个唯一的token,每个页面由多个form的token构成一个组;2)在提交时,前端将token和token组传递给后台,后台通过组中存放的每个form的...
【专利技术属性】
技术研发人员:王承明,
申请(专利权)人:成都萌想科技有限责任公司,
类型:发明
国别省市:四川,51
还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。