Ejemplo n.º 1
0
 /** 修改用户头像 */
 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";
 }
Ejemplo n.º 2
0
 /** 修改密码 */
 public String ChangePwd() {
   userService.updateUser(user); // 更新密码
   return "ChangePwd";
 }
Ejemplo n.º 3
0
 /** 修改用户中心的用户信息 */
 public String ChangeMessage() {
   userService.updateUser(user);
   System.out.println(user.getUsername() + "修改个人信息成功");
   return "ChangeUserMess";
 }