chengeaction.java

来自「struts+hibernate简单的例子」· Java 代码 · 共 32 行

JAVA
32
字号
package com.brothers.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.brothers.dao.DaoFactory;
import com.brothers.dao.IUserDAO;
import com.brothers.form.ChengeActionForm;
import com.brothers.model.User;
import com.brothers.util.AuthorityUtil;
import com.brothers.util.UserInfo;

public class ChengeAction extends BaseAction {
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		ChengeActionForm chengeForm = (ChengeActionForm) form;
		UserInfo ui = (UserInfo)AuthorityUtil.getUser(request);
		IUserDAO dao = DaoFactory.getUserDAO();
		User ub = (User)dao.getUserById(ui.getUserId());
		if(ub.getUserPwd().equals(chengeForm.getOldUserPwd())){
            ub.setUserPwd(chengeForm.getNewUserPwd());
            dao.updateUser(ub);			
		}
        request.setAttribute("chengeresult", "true");
        return mapping.findForward("chenge");
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?