springboot+vue.js项目碰到的小问题总结

表单提交出现乱码,通过设置这个乱码解决:

response.setHeader("Content-type", "text/html;charset=UTF-8");

 ajax实现前后端调用实现注册时名字检重

    @RequestMapping(value = "registerJudge",method = RequestMethod.POST)
    public String registerJudge(User user, @RequestParam String repassword, HttpServletResponse response, HttpServlet servlet) throws IOException {
        response.setHeader("Content-type", "text/html;charset=UTF-8");
        if(user.getName()==""||user.getPassword()==""||repassword==""){
            response.getWriter().write("信息填写不完整,请重新注册");
            return "register";
        }else{
            logger.info(user.getName()+" "+user.getPassword()+" "+repassword);
            response.getWriter().println("注册成功");
            return "login";
        }
    }

 

你可能感兴趣的:(springboot+vue.js项目碰到的小问题总结)