一种防止页面重复提交的方法技术

技术编号:17618244 阅读:53 留言:0更新日期:2018-04-04 08:48
本发明专利技术涉及计算机应用技术领域,具体的讲涉及一种防止页面重复提交的方法,修改传统的Token令牌机制,采用按组分配的token对象,每个token对象对应1个url请求,所有token对象构成一个token对象组,然后通过token的信号量命中累计,与1进行对比,判断是否重复提交的时候首先在服务器端取出对应这个页面的token组,然后判断组中每个对象和当前请求的token对象是否有信号量加1,如果大于1则为重复提交,终止操作返回错误信息提示;没有,执行业务程序,检测完毕;本发明专利技术通过form产生令牌,不会被修改,同时一个令牌对应一个请求,重复提交的控制是整个页面,可以存放的无限制个数的token组,改方法简单高效,能够有效地防止页面重复提交。

A method of preventing repeated submission of pages

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将不能提交,因为当提交了第一个form后,会话中的令牌将本文档来自技高网...

【技术保护点】
一种防止页面重复提交的方法,其特征在于:修改传统的Token令牌机制,采用按组分配的token对象,每个所述token对象对应1个url请求,所有token对象构成一个token对象组,然后通过token的信号量命中累计,与1进行对比,具体步骤如下:1)在html各个form需要的位置,产生一个唯一的token,每个页面由多个form的token构成一个组;2)在提交时,前端将token和token组传递给后台,后台通过组中存放的每个form的组进行命中存放;3)比对后每个token对应一个令牌,并将令牌放入当前页面对应的这个令牌组中;4)后端判断重复提交的时候,首先取出对应这个页面的toke...

【技术特征摘要】
1.一种防止页面重复提交的方法,其特征在于:修改传统的Token令牌机制,采用按组分配的token对象,每个所述token对象对应1个url请求,所有token对象构成一个token对象组,然后通过token的信号量命中累计,与1进行对比,具体步骤如下:1)在html各个form需要的位置,产生一个唯一的token,每个页面由多个form的token构成一个组;2)在提交时,前端将token和token组传递给后台,后台通过组中存放的每个form的...

【专利技术属性】
技术研发人员:王承明
申请(专利权)人:成都萌想科技有限责任公司
类型:发明
国别省市:四川,51

网友询问留言 已有0条评论
  • 还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。

1