UserModAction.java~25~
上传用户:dlqqsh
上传日期:2021-11-13
资源大小:7840k
文件大小:2k
源码类别:

OA系统

开发平台:

Java

  1. package officeol.mc.actions;
  2. import org.apache.struts.action.ActionMapping;
  3. import org.apache.struts.action.ActionForm;
  4. import javax.servlet.http.HttpServletRequest;
  5. import javax.servlet.http.HttpServletResponse;
  6. import org.apache.struts.action.ActionForward;
  7. import org.apache.struts.action.Action;
  8. import officeol.mc.tools.*;
  9. public class UserModAction extends Action {
  10.     public ActionForward execute(ActionMapping mapping, ActionForm form,
  11.                                  HttpServletRequest request,
  12.                                  HttpServletResponse response) {
  13.         try{
  14.             request.setCharacterEncoding("GBK");
  15.             DBConn dbc = new DBConn();
  16.             Tool tl  = new Tool();
  17.             String unmd5 = request.getParameter("username");
  18.             if(unmd5==null){
  19.                 request.setAttribute("msg", "请选择用户!");
  20.                 return mapping.findForward("err");
  21.             }
  22.             String un = request.getParameter("un");
  23.             String xm = request.getParameter("xm");
  24.             String sex = request.getParameter("sex");
  25.             String tel = request.getParameter("tel");
  26.             String tel2 = request.getParameter("tel2");
  27.             String email = request.getParameter("email");
  28.             String sql = "update [user] set xingming = '"+xm+"',sex = '"+sex+"',tel = '"
  29.                          +tel+"',tel2 = '"+tel2+"',email = '"+email+"' where unmd5='"+unmd5+"' ";
  30.             int i = dbc.executeUpdate(sql);
  31.             if(i!=0){
  32.                 request.setAttribute("msg", "用户 " + un + " 修改成功!");
  33.                 return mapping.findForward("succ");
  34.             }else{
  35.                 request.setAttribute("msg", "用户 " + un + " 修改出错,请重试!");
  36.                 return mapping.findForward("err");
  37.             }
  38.         }catch(Exception ex){
  39.             ex.printStackTrace();
  40.             request.setAttribute("msg","用户修改出现异常,请重试!");
  41.         }
  42.         return mapping.findForward("err");
  43.     }
  44. }