文件名称:北大青鸟超市管理系统
文件大小:2.02MB
文件格式:RAR
更新时间:2016-05-22 04:30:21
超市管理系统
package com.pb.supermanager.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.pb.supermanager.dao.UserDao; import com.pb.supermanager.dao.impl.UserDaoImpl; import com.pb.supermanager.entity.User; import com.pb.supermanager.service.impl.UserServiceImpl; public class UserAdd extends HttpServlet { private static final long serialVersionUID = -6316960884845775373L; public UserAdd() { super(); } public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { UserServiceImpl userService=new UserServiceImpl(); UserDao userDao=new UserDaoImpl(); userService.setUserDao(userDao); request.setCharacterEncoding("utf-8"); int userId=Integer.parseInt(request.getParameter("userId")); String userName = request.getParameter("username"); String userPassword = request.getParameter("password"); String userGender = request.getParameter("sex"); int userAge = Integer.parseInt(request.getParameter("age")); int userTell = Integer.parseInt(request.getParameter("mobile")); String userAddress = request.getParameter("address"); String userPri = request.getParameter("auth"); User user=new User(); user.setUserId(userId); user.setUserName(userName); user.setUserPassword(userPassword); user.setUserGender(userGender); user.setUserAge(userAge); user.setUserTell(userTell); user.setUserAddress(userAddress); user.setUserPri(userPri); boolean flag=userService.addUser(user); if(flag==true){ response.sendRedirect("jsp/userAdmin.jsp"); }else { response.sendRedirect("jsp/userAdd.jsp"); } } public void init() throws ServletException { // Put your code here } }