📄 editaccountlinkaction.java
字号:
/* * XP Forum * * Copyright (c) 2002-2003 RedSoft Group. All rights reserved. * */package org.redsoft.forum.web;import org.apache.struts.action.Action;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import org.redsoft.forum.ForumConstants;import org.redsoft.forum.dao.Account;import org.redsoft.forum.dao.AccountDAO;import org.redsoft.forum.dao.DAOFactory;import org.redsoft.forum.exception.AccountNotFoundException;import org.redsoft.forum.exception.DAOException;import org.redsoft.forum.security.User;import javax.security.auth.Subject;import javax.servlet.ServletException;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.io.IOException;/** * A actino that wraps the link to editAccount.jsp * * @author Charles Huang * * @version 1.0 */public class EditAccountLinkAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Get the user from session final Subject subject = (Subject)request.getSession().getAttribute(ForumConstants.USER_KEY); final String user = ( (User)subject.getPrincipals( User.class ).iterator().next() ).getName();/* // If user is null then user has not loged in,forward to log on screen if ( user == null || user.length() == 0 ){ final String url = "/account.go"; request.setAttribute( ForumConstants.DEST_URL, url ); return (mapping.findForward("logon")); }else{*/ try{ final AccountDAO dao = DAOFactory.getInstance().getAccountDAO(); final Account account = dao.findByUserName( user ); request.setAttribute( ForumConstants.ACCOUNT, account ); }catch( final DAOException daoException ){ daoException.printStackTrace(); return (mapping.findForward("error")); }catch( final AccountNotFoundException accountNotFoundException) { accountNotFoundException.printStackTrace(); return (mapping.findForward("error")); } // Forward control to the specified success URI return (mapping.findForward("success"));/* }*/ }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -