gistfile1.txt private void updatemyself(HttpServletRequest request, HttpServletResponse response) {String uid = request.getParameter("uid") == null ? "": request.getParameter("uid");String username = request.getParameter("username") == null
private void updatemyself(HttpServletRequest request, HttpServletResponse response) { String uid = request.getParameter("uid") == null ? "" : request.getParameter("uid"); String username = request.getParameter("username") == null ? "" : request.getParameter("username"); String cusername = request.getParameter("cusername") == null ? "" : request.getParameter("cusername"); String password = request.getParameter("password") == null ? "" : request.getParameter("password"); String roleId = request.getParameter("role") == null ? "" : request.getParameter("role"); String levelId = request.getParameter("level") == null ? "" : request.getParameter("level"); Mapmap = new HashMap (); if (!"".equals(username) && !"".equals(password)&&!"".equals(uid)&&!"".equals(roleId)&&!"".equals(levelId)) { User user = new User(); user.setUid(Integer.valueOf(uid)); user.setUserName(username); user.setCuserName(cusername); user.setPassword(password); Role role=new Role(); role.setRoleId(roleId); Level level=new Level(); level.setLevelId(Integer.valueOf(levelId)); user.setLevel(level); user.setRole(role); if (userDao.update(user)) { map.put("msg", "修改成功!"); } else { map.put("msg", "修改失败!"); } List list = userDao.find(user); if (list.size() == 1) { user=list.get(0); request.getSession().setAttribute("webuser", user); } } else { map.put("msg", "数据存在空值."); } JSONObject json = JSONObject.fromObject(map); try { response.setContentType("application/json;charset=utf-8"); response.getWriter().print(json); } catch (IOException e) { e.printStackTrace(); } }