首页 > 解决方案 > 如果用户直接输入链接,我如何重定向到某个 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>

标签: javahtmlspring-boot

解决方案


推荐阅读