UserRegisterServlet代码如下:
@WebServlet("/user_rigister")
public class UserRegisterServlet extends HttpServlet {
private UserService uService = new UserService();
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
User user = new User();
try {
BeanUtils.copyProperties(user, request.getParameterMap());
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(uService.register(user)) {
request.setAttribute("msg", "注册成功,请登录!");
request.getRequestDispatcher("user_login.jsp").forward(request, response);
}else {
request.setAttribute("msg", "用户名或邮箱重复,请重新填写!");
request.getRequestDispatcher("user_register.jsp").forward(request, response);
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
}
}
黑马程序员JavaWeb程序设计第2版的网上蛋糕商城源码压缩包,完整齐全,可运行
本文转载自: https://blog.csdn.net/qq_59758616/article/details/128361873
版权归原作者 bug笔记本 所有, 如有侵权,请联系我们删除。
版权归原作者 bug笔记本 所有, 如有侵权,请联系我们删除。