问题:
代码环境
原因:
- 代码自动继承了父类的方法
super.doPost(req, resp)
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
super.doPost(req, resp);
String username = req.getParameter("username");
String password = req.getParameter("password");
String email = req.getParameter("email");
String code = req.getParameter("code");
if("abcde".equalsIgnoreCase(code)){
if (userService.existsUsername(username)) {
System.out.println("用户名已存在");
req.getRequestDispatcher("/pages/user/regist.html").forward(req, resp);
}else{
userService.registUser(new User(null,username,password,email));
req.getRequestDispatcher("/pages/user/regist_success.html").forward(req, resp);
}
}else{
System.out.println("验证码错误["+code+"]错误");
req.getRequestDispatcher("/pages/user/regist.html").forward(req, resp);
}
}
解决方法:
- 将
super.doPost(req, resp) 代码去掉
|