MyInfo.java
资源名称:Myblog.rar [点击查看]
上传用户:wlfwy2004
上传日期:2016-12-12
资源大小:33978k
文件大小:3k
源码类别:
Jsp/Servlet
开发平台:
Java
- package com.opensource.blog.web.action;
- import javax.servlet.http.*;
- import org.apache.commons.beanutils.*;
- import org.apache.struts.action.*;
- import com.opensource.blog.comm.BlogUtil;
- import com.opensource.blog.exception.*;
- import com.opensource.blog.model.*;
- import com.opensource.blog.service.*;
- import com.opensource.blog.web.form.*;
- import com.opensource.blog.web.servlet.*;
- public class MyInfo
- extends BaseAction {
- private UserInfoService userInfoService;
- public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse servletResponse) {
- ActionMessages errors = new ActionMessages();
- MyInfoForm form = (MyInfoForm) actionForm;
- UserSession us = this.getUserSession(servletRequest);
- if (form.getAction().equalsIgnoreCase("show")) {
- form.setAction("edit");
- form.setAddress(us.getUserInfo().getAddress());
- form.setAge(us.getUserInfo().getAge());
- form.setCity(us.getUserInfo().getCity());
- form.setEdulevel(us.getUserInfo().getEdulevel());
- form.setEmail(us.getUserInfo().getEmail());
- form.setFace(us.getUserInfo().getFace());
- form.setIncome(us.getUserInfo().getIncome());
- form.setIndustry(us.getUserInfo().getIndustry());
- form.setMb(us.getUserInfo().getMb());
- form.setNickname(us.getUserInfo().getNickname());
- form.setPro(us.getUserInfo().getPro());
- form.setSex(us.getUserInfo().getSex());
- form.setSign(us.getUserInfo().getSign());
- form.setWork(us.getUserInfo().getWork());
- return actionMapping.findForward("myinfo");
- }
- if (form.getAction().equalsIgnoreCase("edit")) {
- UserInfo ui = us.getUserInfo();
- try {
- BeanUtils.copyProperties(ui, form);
- }
- catch (Exception e) {
- }
- try {
- ui = this.getUserInfoService().saveUserInfo(ui);
- }
- catch (BlogException ex) {
- errors.add("error.myinfo.upinfo", new ActionMessage("error.myinfo.upinfo"));
- saveErrors(servletRequest, errors);
- return actionMapping.findForward("error");
- }
- this.saveUserSession(servletRequest, ui);
- ActionForward f = new ActionForward(BlogUtil.getResultUrl("info.up.well", "myInfo.do"), true);
- return f;
- }
- return actionMapping.findForward("error");
- }
- public UserInfoService getUserInfoService() {
- return userInfoService;
- }
- public void setUserInfoService(UserInfoService userInfoService) {
- this.userInfoService = userInfoService;
- }
- }