package servlet; import java.io.IOException; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import dao.User; import dao.userDao; import dao.kUser; public class admin extends HttpServlet { /** * */ private static final long serialVersionUID = 1L; public admin() { 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 { doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); String zsgc = request.getParameter("zsgc").replace(" ", ""); if(zsgc.equals("dl")){ dlAdmin(request, response); }else if(zsgc.equals("zj")){ addkUser(request, response); allkUser(request, response); }else if(zsgc.equals("xg")){ updatekUser(request, response); allkUser(request, response); }else if(zsgc.equals("sc")){ delectkUser(request, response); allkUser(request, response); }else{ request.getRequestDispatcher("error.jsp").forward(request, response); } } public void init() throws ServletException { // Put your code here } private void dlAdmin(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ String name = request.getParameter("word").replace(" ", ""); String pass = request.getParameter("pass"); User user = new User(); user.setU_word(name); user.setU_pass(pass); if(new userDao().adminUser(user)){ request.getSession().setAttribute("gly", name); allkUser(request, response); }else{ request.getRequestDispatcher("admin.jsp").forward(request, response); } } private void addkUser(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ String kcm = request.getParameter("kcm").replace(" ", ""); String js = request.getParameter("js"); String jxl = request.getParameter("jxl"); String sj =request.getParameter("sj"); String xf = request.getParameter("xf"); kUser kuser = new kUser(); kuser.setK_kcm(kcm); kuser.setK_js(js); kuser.setK_jxl(Integer.parseInt(jxl)); kuser.setK_sj(sj); kuser.setK_xf(Integer.parseInt(xf)); new userDao().addkUser(kuser); } private void updatekUser(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ String id =request.getParameter("id"); String kcm = request.getParameter("kcm").replace(" ", ""); String js = request.getParameter("js"); String jxl = request.getParameter("jxl"); String sj =request.getParameter("sj"); String xf = request.getParameter("xf"); //System.out.println(id+"---"+kcm+"---"+js+"---"+jxl+"---"+sj+"---"+xf); kUser kuser = new kUser(); kuser.setK_id(Integer.parseInt(id)); kuser.setK_kcm(kcm); kuser.setK_js(js); kuser.setK_jxl(Integer.parseInt(jxl)); kuser.setK_sj(sj); kuser.setK_xf(Integer.parseInt(xf)); new userDao().updatekUser(kuser); } private void delectkUser(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ String id =request.getParameter("id"); kUser kuser = new kUser(); kuser.setK_id(Integer.parseInt(id)); new userDao().deletekUser(kuser); } private void allkUser(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ List<kUser> kuser=new userDao().getAllkUser(); request.getSession().setAttribute("bgkUser", kuser); request.getRequestDispatcher("/background.jsp").forward(request, response); } }
最近下载更多
chen000 LV4
6月27日
hongdongdong LV14
5月7日
asddwh LV13
2023年12月26日
2036495585 LV9
2023年9月25日
qwqwqw12345 LV3
2023年6月20日
ppooppoo932 LV4
2023年6月7日
1WQAQW1 LV2
2023年6月7日
qiangmin1223 LV12
2023年4月24日
KrisNo10000 LV2
2023年3月1日
linkai8165 LV8
2023年1月30日
最近浏览更多
PISCESPLUS LV4
9月3日
chen000 LV4
6月27日
慵懒的小橘猫 LV11
6月8日
wangbh1234 LV1
6月7日
微信网友_7000012089643008 LV4
5月26日
hyt123456 LV3
5月9日
op123129
4月15日
暂无贡献等级
Lilei66
3月27日
暂无贡献等级
logan123
3月17日
暂无贡献等级
222dsff
1月5日
暂无贡献等级