首页>代码>s2sh开发的网页通讯录后台管理项目,学习用的>/JavaWebProject/src/com/kechengsheji/action/ChangePasswordAction.java
package com.kechengsheji.action;

import com.opensymphony.xwork2.ActionContext;
import com.kechengsheji.dao.AdminDAO;
import com.kechengsheji.domain.Admin;

public class ChangePasswordAction {
	
	private String oldPassword;
	private String newPassword;
	private String newPassword2;
	
	
	public String getOldPassword() {
		return oldPassword;
	}


	public void setOldPassword(String oldPassword) {
		this.oldPassword = oldPassword;
	}


	public String getNewPassword() {
		return newPassword;
	}


	public void setNewPassword(String newPassword) {
		this.newPassword = newPassword;
	}


	public String getNewPassword2() {
		return newPassword2;
	}


	public void setNewPassword2(String newPassword2) {
		this.newPassword2 = newPassword2;
	}


	/*修改密码*/
	public String execute() {
		ActionContext ctx = ActionContext.getContext(); 
		if(oldPassword.equals("")) {
			ctx.put("error",  java.net.URLEncoder.encode("旧密码必须输入!"));
			return "error";
		}
		if(newPassword.equals("")) {
			ctx.put("error",  java.net.URLEncoder.encode("新密码必须输入!"));
			return "error";
		}
		if(!newPassword2.equals(newPassword)) {
			ctx.put("error",  java.net.URLEncoder.encode("两次密码输入不一致!"));
			return "error";
		}
		String username = (String)ctx.getSession().get("username"); 
		Admin admin = AdminDAO.GetAdmin(username);
		if(!admin.getPassword().equals(oldPassword)) {
			ctx.put("error",  java.net.URLEncoder.encode("旧密码不正确!"));
			return "error";
		}
		
		try { 
			AdminDAO.ChangePassword(username,newPassword);
			ctx.put("message",  java.net.URLEncoder.encode("密码修改成功!"));
			return "change_success";
		} catch (Exception e) {
			e.printStackTrace();
			ctx.put("error",  java.net.URLEncoder.encode("密码更新失败!"));
			return "error";
		}  
		
	}

}
最近下载更多
and123456  LV11 2022年3月16日
644800782  LV4 2022年3月1日
刘可心  LV2 2021年3月20日
2215593477  LV9 2021年1月11日
liangge2115  LV27 2020年7月15日
双方各何必呢  LV13 2020年7月2日
EternalIy  LV4 2020年6月17日
大杰打劫  LV8 2020年3月24日
ljlssb  LV1 2019年12月16日
yawy007  LV4 2019年12月6日
最近浏览更多
哈哈ha zhh  LV2 2023年11月7日
haoghuang 2023年1月3日
暂无贡献等级
3473084268  LV7 2022年12月11日
欧神1327 2022年12月11日
暂无贡献等级
Yier123  LV8 2022年9月30日
北末qwert  LV2 2022年5月18日
暂无贡献等级
sunflower3 2022年5月13日
暂无贡献等级
xcwDeng0001  LV5 2022年3月13日
644800782  LV4 2022年3月1日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友