Request method 'GET' not supported

今天做登录和注册的时候出现了这个问题,百度之后说是

 

即提交的表单字段要与bean的类型完全对应,否则请求并不能完全对应识别。

然后改了程序里面的句子。登录和注册页面要对应起来就可以

这是登录的程序:pass+count.getSalt()原来写的是count.getUser();

 

@RequestMapping(value = "login", method = RequestMethod.POST)
public String login(HttpServletResponse response, HttpServletRequest request, @RequestParam("user") String user, @RequestParam("pass") String pass) throws Exception {
    if (user != null && !user.equals("")) {
        Count count = countServiceImpl.selectByName(user);
        if (count.getUser().equals(user)) {
            if (MD5Util.MD5(pass + count.getSalt()).equals(count.getMd5())) {
                Long db = System.currentTimeMillis();
                String df = db.toString();
                String tokenz = user + "," + df;
                String token = EncryUtil.encrypt(tokenz);
                Cookie cookie = new Cookie("name", token);
                //cookie.setDomain("www.h.top");
                cookie.setPath("/");
                cookie.setMaxAge(1000 * 60 * 60);
                response.addCookie(cookie);
                return "redirect:/u/one";
            }
        }
    }
    return "redirect:/login";
}

而注册的逻辑写的是:

 

@RequestMapping(value = "register",method = RequestMethod.POST)
public String register(@RequestParam("user") String user,@RequestParam("pass") String pass,@RequestParam("online") String online,@RequestParam("workers") String workers) throws Exception{
        int check = countServiceImpl.countByName(user);
        if(check>0){
            return "register";
        } else {
            String salt = UUIDUtil.getUUID();
            String MD5 = MD5Util.MD5(pass+salt);
            Count count = new Count();
            count.setPass(pass);
            count.setOnline(online);
            count.setWorkers(user);
            count.setSalt(salt);
            count.setUser(user);
            count.setMd5(MD5);
            countServiceImpl.insert(count);
            return "login";
        }

MD5(是pass+salt),要对应才行。

x

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值