コード例 #1
0
ファイル: UserCenterAction.java プロジェクト: xxyexx/pocc
  /** 检验旧密码的ajax */
  public String CheckPwd() {
    if (user.getPassword().equals(MD5Util.md5Encode(Pwd))) {
      oldPwdResult = "pwdCorrect"; // 密码正确
    } else {
      oldPwdResult = "pwdWrong"; // 密码错误
    }

    return "CheckPwd";
  }
コード例 #2
0
ファイル: UserCenterAction.java プロジェクト: xxyexx/pocc
 /** 修改用户头像 */
 public String ChangePic() {
   String realpath = ServletActionContext.getServletContext().getRealPath("/image/userPic");
   // D:/apache-tomcat-6.0.18/webapps/pocc/image/userPic
   if (image != null) { // 先删除旧头像
     File f =
         new File(ServletActionContext.getServletContext().getRealPath("/") + user.getIcon_url());
     if (f.exists()) f.delete();
     // 再写入新头像,为了防止名字重复,账户+图片名称
     File savefile = new File(new File(realpath), user.getUser_account() + imageFileName);
     if (!savefile.getParentFile().exists()) savefile.getParentFile().mkdirs();
     try {
       FileUtils.copyFile(image, savefile);
     } catch (IOException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
     user.setIcon_url("image/userPic/" + user.getUser_account() + imageFileName);
     userService.updateUser(user); // 更新数据库头像url
     System.out.println(user.getUsername() + "修改头像成功");
   }
   return "ChangePic";
 }
コード例 #3
0
ファイル: UserInterceptor.java プロジェクト: xxyexx/pocc
  @Override
  public String intercept(ActionInvocation invocation) throws Exception {
    String result = null;
    //		System.out.println("request:"+ServletActionContext.getRequest().getParameter("user_id"));
    if (ServletActionContext.getRequest().getSession().getAttribute("User") != null) { // 已登录
      User user = (User) ServletActionContext.getRequest().getSession().getAttribute("User");
      // 获取请求的action名称
      String actionName = invocation.getInvocationContext().getName();

      System.out.println("actionName=" + actionName);
      if (actionName.equals("beginTest") || actionName.equals("showPoccFile")) { // 正在实验
        System.out.println("正在实验");
        if (ServletActionContext.getRequest().getSession().getAttribute("testingStudentList")
            == null) { // 空
          List<Integer> studentList = new ArrayList<Integer>();
          studentList.add(user.getUser_id());
          ServletActionContext.getRequest()
              .getSession()
              .setAttribute("testingStudentList", studentList);
        } else { // 加入实验列表
          List<Integer> studentList =
              (List<Integer>)
                  ServletActionContext.getRequest().getSession().getAttribute("testingStudentList");
          if (studentList.contains(user.getUser_id())) { // 已存在
          } else { // 不存在
            studentList.add(user.getUser_id());
          }
        }
      } else { // 不在实验
        if (ServletActionContext.getRequest().getSession().getAttribute("testingStudentList")
            != null) { // 空
          List<Integer> studentList =
              (List<Integer>)
                  ServletActionContext.getRequest().getSession().getAttribute("testingStudentList");
          if (studentList.contains(user.getUser_id())) { // 存在
            studentList.remove(new Integer(user.getUser_id()));
          }
        }
      }
      result = invocation.invoke(); // 执行Action的exceute等方法
    } else { // 未登录
      result = Action.LOGIN;
    }
    return result;
  }
コード例 #4
0
ファイル: UserCenterAction.java プロジェクト: xxyexx/pocc
 /** 修改用户中心的用户信息 */
 public String ChangeMessage() {
   userService.updateUser(user);
   System.out.println(user.getUsername() + "修改个人信息成功");
   return "ChangeUserMess";
 }
コード例 #5
0
ファイル: UserCenterAction.java プロジェクト: xxyexx/pocc
 /** 显示用户信息 设置城市列表 */
 public String Show() {
   Map<Integer, String> provinceMap = CityUtil.getProvince_all();
   request.setAttribute("ProvinceMap", provinceMap);
   System.out.println(user.getProvince_name());
   return "UserCenter.jsp";
 }