⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 updatepasswordaction.java

📁 这个是完整的wap项目的源码 开发语言 Java 系统架构 Struts + hibernate + spring 数据库 Mysql5.0 应用服务器Tomcat5.0 开发工具 MyEc
💻 JAVA
字号:
package com.longtime.wap.module.user.web.action;

import java.util.ArrayList;
import java.util.List;

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

import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.web.struts.DispatchActionSupport;

import com.longtime.wap.common.WapConstant;
import com.longtime.wap.frame.common.UserSessionVO;
import com.longtime.wap.model.UserInfo;
import com.longtime.wap.module.user.service.UserInfoService;
import com.longtime.wap.module.user.web.form.UpdatePasswordForm;

/**
 * 处理修改请求
 * 
 * @author baolj
 * @date Nov 20, 2007 
 */
public class UpdatePasswordAction extends DispatchActionSupport {

	private UserInfoService userInfoService = null;

	/**
	 * 注入服务对象
	 * 
	 * @param userInfoService
	 *            设置服务对象
	 */
	public void setUserInfoService(UserInfoService userInfoService) {
		this.userInfoService = userInfoService;
	}

	/**
	 * 初始化
	 * 
	 * @param mapping
	 *            ActionMapping对象
	 * @param form
	 *            ActionForm对象
	 * @param request
	 *            HttpServletRequest对象
	 * @param response
	 *            HttpServletResponse对象
	 * @return ActionForward对象
	 * @throws Exception
	 * 				异常
	 */
	public ActionForward init(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		return mapping.findForward("updatePassword");
	}

	/**
	 * 保存密码
	 * 
	 * @param mapping
	 *            ActionMapping对象
	 * @param form
	 *            ActionForm对象
	 * @param request
	 *            HttpServletRequest对象
	 * @param response
	 *            HttpServletResponse对象
	 * @return ActionForward对象
	 * @throws Exception
	 * 				异常
	 */
	@SuppressWarnings("unchecked")
	public ActionForward savePassword(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		ActionErrors errors = new ActionErrors();
		UserInfo userInfo = null;
		UserSessionVO usVo = (UserSessionVO) request.getSession().getAttribute(
				WapConstant.USER_SESSION);
		UpdatePasswordForm updatePwdForm = (UpdatePasswordForm) form;
		userInfo = userInfoService.getUserInfoById(usVo.getUserId());

		if (updatePwdForm.getOripassWord().equals(userInfo.getPassword())) {
			userInfo.setPassword(updatePwdForm.getPassWord());
			userInfoService.saveUserInfo(userInfo);
			List<String> messages = new ArrayList<String>();
			messages.add("保存成功");
			request.setAttribute(WapConstant.WAP_GLOBAL_MESSAGES, messages);
		} else {
			// wrong password
			ActionError error = new ActionError("modify.password.notmatch");
			errors.add("oripassWord", error);
			saveErrors(request, errors);
			updatePwdForm.setOripassWord("");
			updatePwdForm.setPassWord("");
			updatePwdForm.setAffirmnewpass("");
			return mapping.findForward("updatePassword");
		}
		return mapping.findForward("success");
	}

	/**
	 * 返回
	 * 
	 * @param mapping
	 *            ActionMapping对象
	 * @param form
	 *            ActionForm对象
	 * @param request
	 *            HttpServletRequest对象
	 * @param response
	 *            HttpServletResponse对象
	 * @return ActionForward对象
	 * @throws Exception
	 * 				异常
	 */
	public ActionForward back(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		return mapping.findForward("success");
	}
}

⌨️ 快捷键说明

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