UserRegisterServlet代码如下:文章来源:https://www.toymoban.com/news/detail-775749.html
@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);
}
}
文章来源地址https://www.toymoban.com/news/detail-775749.html
到了这里,关于JavaWeb程序设计第2版网上蛋糕商城源码压缩包的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!