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

📄 nickname.java

📁 天乙社区6.0是一套基于JAVA技术的网络虚拟社区
💻 JAVA
字号:
package com.laoer.bbscs.web.action;

import com.laoer.bbscs.web.form.*;
import com.laoer.bbscs.bean.*;
import com.laoer.bbscs.sys.*;
import com.laoer.bbscs.web.servlet.*;
import org.apache.struts.action.*;
import javax.servlet.http.*;

/**
 * <p>Title: TianYi BBS</p>
 * <p>Description: TianYi BBS System</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: LAOER.COM/TIANYISOFT.NET</p>
 * @author laoer
 * @version 6.0
 */

public class Nickname
    extends BaseAction {

  public ActionForward execute(ActionMapping actionMapping,
                               ActionForm actionForm,
                               HttpServletRequest httpServletRequest,
                               HttpServletResponse httpServletResponse) {
    ActionErrors errors = new ActionErrors();
    NicknameForm form = (NicknameForm) actionForm;
    UserCheck uc = this.getUserCheck(httpServletRequest, httpServletResponse,
                                     Constant.MESSAGE.getMessage(
                                         httpServletRequest.getLocale(),
                                         "place.nickname"));
    if (uc.isGuest()) {
      errors.add("error.pleaselogin", new ActionError("error.pleaselogin"));
      saveErrors(httpServletRequest, errors);
      LoginForm loginForm = new LoginForm();
      loginForm.setTourl(SysUtil.getToURL(httpServletRequest,
                                          "nickname" + Constant.FILEPREFIX));
      /*
       loginForm.setTourl(SysUtil.encodeURL("nickname" + Constant.FILEPREFIX,
                                           Constant.CHARSET));*/
      httpServletRequest.setAttribute("loginForm", loginForm);

      //return actionMapping.findForward("login");
      return SysUtil.getPassLogin(actionMapping);
    }
    if (form.getAction().equals("show")) {
      form.setAction("modnickname");
      httpServletRequest.setAttribute("nicknameForm", form);
      return actionMapping.findForward("nickname");
    }
    if (form.getAction().equals("modnickname")) {
      //UserInfo ui = getUserInfoService().findUserInfoById(new Long(uc.getId()));
      UserInfo ui = this.getUserCache().getUserInfoFromCache(uc.getId());
      if (ui == null) {
        errors.add("error.getusererror", new ActionError("error.getusererror"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      ui.setNickname(form.getNickname());
      ui = getUserInfoService().saveUserInfo(ui);
      if (ui == null) {
        errors.add("error.changenickname",
                   new ActionError("error.changenickname"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      uc.addCookies(ui);
      this.getUserCache().putUserInfoInCache(ui);
      ActionForward f = new ActionForward(SysUtil.getResultUrl(
          "succeed.changenickname", "in" + Constant.FILEPREFIX), true);
      return f;
    }
    return actionMapping.findForward("error");
  }
}

⌨️ 快捷键说明

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