java - 如果用户直接输入链接,我如何重定向到某个 url。此外,如果按钮已经存在于特定的 url(在 spring boot 中)
问题描述
我有一个 post 方法,它只是将一些内容更新到我的数据库,但存在漏洞我已经解决了这个方法,使用 javascript 使用 onclick 按钮,当按钮单击时,它会阻止按钮 10 秒,但是当我尝试使用直接 URL 时,它不会禁用按钮30秒为什么?
这是我的帖子映射代码
@RequestMapping(value = "/Balnce_add", method ={RequestMethod.POST, RequestMethod.GET})
public ModelAndView GoesUp(@AuthenticationPrincipal CustomUserDetails currentuser) throws IOException {
if (isAuthenticated()) {
int x=currentuser.getBalance() +10;
currentuser.setBalance(x);
repo.setUserInfoById(x,currentuser.getId());
repoofdata.setDataInfoById(x,currentuser.getId());
System.out.println(currentuser.getName()+" (new balance) ==> " +currentuser.getBalance());
return new ModelAndView("redirect:"+"/game1"); // here game1 is HTML page with getmapping
}
return new ModelAndView("redirect:"+"/signin"); // here signing is HTML page with getmapping
}
这是我的 HTML 代码,带有点击 javascript 功能
<button id="upside" onclick="up(true)" type="submit" class="btn btn-success">Up</button>
解决方案
推荐阅读
- javascript - Vue.js 表格排序 (HTML & Buefy)
- javascript - 通过 JS 清除 cookie 但 PHP 仍然检测到它
- augmented-reality - 可以为 AR.js 使用任何无边界自定义标记
- c# - 从其他表单搜索数据不起作用?
- json - 在 Swift 中使用 Campaign Monitor 的 HTTP 身份验证请求
- phaser-framework - 我应该使用 Phaser 3 还是 Phaser 2/CE?
- c++ - tensorflow 是否定义了 USE_GEMM_FOR_CONV
- python - Python - 防止子线程受到 SIGINT 信号的影响
- ruby - Ruby - 检查 API 响应参数中是否存在特定的 int
- jenkins - 无法设置环境变量“CHANGE_TITLE”的值