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

📄 personalinfoeditaction.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.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.PersonalInfoModifyFrom;

/**
 * 处理修改请求
 * 
 * @author baolj
 * @date Nov 20, 2007 
 */
public class PersonalInfoEditAction 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对象
	 */
	public ActionForward editPersonal(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		PersonalInfoModifyFrom personalInfoForm = (PersonalInfoModifyFrom)form;
		UserSessionVO usVo = (UserSessionVO)request.getSession().
		getAttribute(WapConstant.USER_SESSION);
		UserInfo userInfo = userInfoService.
		getUserInfoById(new Long(usVo.getUserId()));
		personalInfoForm.setUserName(userInfo.getUserName());
		personalInfoForm.setRemark(userInfo.getMemo());
		return mapping.findForward("init");
	}
	
	/**
	 * 保存管理员个人资料信息
	 * 
	 * @param mapping
	 *            ActionMapping对象
	 * @param form
	 *            ActionForm对象
	 * @param request
	 *            HttpServletRequest对象
	 * @param response
	 *            HttpServletResponse对象
	 * @return ActionForward对象
	 * @throws Exception
	 * 				异常
	 */
	public ActionForward savePersonal(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) 
	throws Exception {
		PersonalInfoModifyFrom personalInfoForm = (PersonalInfoModifyFrom)form;
		UserSessionVO usVo = (UserSessionVO)request.getSession().
		getAttribute(WapConstant.USER_SESSION);
		UserInfo userInfo = userInfoService.getUserInfoById(
				new Long(usVo.getUserId()));
		userInfo.setUserName(personalInfoForm.getUserName().trim());
		userInfo.setMemo(personalInfoForm.getRemark());
		userInfoService.saveUserInfo(userInfo);
		
		//save message
		List<String> messages = new ArrayList<String>();
		messages.add("保存成功");
		request.setAttribute(WapConstant.WAP_GLOBAL_MESSAGES, messages);
				
		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 + -