📄 editaccountlinkaction.java
字号:
/*
* XP Forum
*
* Copyright (c) 2002-2003 RedSoft Group. All rights reserved.
*
*/
package org.redsoft.forum.web;
import org.apache.struts.action.*;
import org.apache.struts.util.RequestUtils;
import org.redsoft.forum.exception.ThreadNotFoundException;
import org.redsoft.forum.ForumConstants;
import org.redsoft.forum.security.User;
import org.redsoft.forum.util.ForumUtils;
import org.redsoft.forum.dao.AccountDAO;
import org.redsoft.forum.dao.DAOFactory;
import org.redsoft.forum.dao.PersistentThread;
import org.redsoft.forum.exception.AccountNotFoundException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import javax.security.auth.Subject;
import java.io.IOException;
import java.sql.SQLException;
/**
* A actino that wraps the link to editAccount.jsp
*
* @author Charles Huang
*
* @version 1.0
*/
public class EditAccountLinkAction extends Action {
public ActionForward perform(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 SQLException sqlException ){
sqlException.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"));
/*
}
*/
}
}//EOC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -