<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    夢幻之旅

    DEBUG - 天道酬勤

       :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      671 隨筆 :: 6 文章 :: 256 評論 :: 0 Trackbacks
    異常攔截器:
    package org.roadway.lm.util;

    import org.apache.log4j.Logger;

    import com.opensymphony.xwork2.ActionInvocation;
    import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

    /**
     * 
    @author Huyvanpull
     * 
     
    */
    @SuppressWarnings(
    "serial")
    public class ExceptionInterceptor extends AbstractInterceptor
    {
        
    private Logger logger = Logger.getLogger(ExceptionInterceptor.class);
        
        
    private String interceptorName;
        
        @Override
        
    public String intercept(ActionInvocation invocation) throws Exception
        {
            
    this.logger.debug("進入" + this.getInterceptorName());
            String result 
    = null;
            
    try
            {
                result 
    = invocation.invoke();
            }
            
    catch (Exception exception)
            {
                
    this.logger.error(this.getExceptionInfo(exception));
                
    throw exception;
            }
            
    return result;
        }
        
        
    private String getExceptionInfo(Exception exception)
        {
            StringBuffer bExceptionInfo 
    = new StringBuffer();
            bExceptionInfo.append(exception.toString());
            bExceptionInfo.append(
    "\n\t");
            
            StackTraceElement[] stackTraceElements 
    = exception.getStackTrace();
            
    for (int i = 0; i < stackTraceElements.length; i++)
            {
                bExceptionInfo.append(
    "[" + this.getInterceptorName() + ""
                        
    + stackTraceElements[i].toString() + "\n\t");
            }
            
    return bExceptionInfo.toString();
        }
        
        
    public String getInterceptorName()
        {
            
    return interceptorName;
        }
        
        
    public void setInterceptorName(String interceptorName)
        {
            
    this.interceptorName = interceptorName;
        }
        
    }

    登陸檢查攔截器:
    package org.roadway.lm.util;

    import java.util.Map;

    import org.apache.log4j.Logger;
    import org.roadway.lm.po.UserInfo;
    import org.roadway.lm.user.action.UserInfoAction;

    import com.opensymphony.xwork2.Action;
    import com.opensymphony.xwork2.ActionInvocation;
    import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

    /**
     * 
    @author tom_hui
     * 
     
    */
    @SuppressWarnings(
    "serial")
    public class LoginCheckerInterceptor extends AbstractInterceptor
    {
        
    private String userSessionKey = "userInfo";
        
        
    private String isCheckLogin   = "true";
        
        
    private Logger logger         = Logger
                                              .getLogger(LoginCheckerInterceptor.
    class);
        
        @SuppressWarnings(
    "unchecked")
        
    public String intercept(ActionInvocation actionInvocation) throws Exception
        {
            Object action 
    = actionInvocation.getAction();
            
            
    /** 如果設置攔截器不檢查登陸 */
            
    if ("false".equalsIgnoreCase(isCheckLogin))
            {
                actionInvocation.invoke();
            }
            
    /** 如果是登陸Action,放其通行 */
            
    if (action instanceof UserInfoAction)
            {
                
    this.logger.info("登陸Action:" + UserInfoAction.class.getName());
                
    return actionInvocation.invoke();
            }
            
            
    /** 從session中得到UserInfo的信息 */
            Map session 
    = actionInvocation.getInvocationContext().getSession();
            UserInfo userInfo 
    = (UserInfo) session.get(userSessionKey);
            
            
    /** 如果Session中存在UserInfo對象 */
            
    if (userInfo != null)
            {
                
    this.logger.info("用戶" + userInfo.getUserName() + "("
                        
    + userInfo.getUserId() + ")登陸了.");
                
    return actionInvocation.invoke();
                
            }
            
    /** 如果沒有登陸 */
            
    else
            {
                
    return Action.LOGIN;
            }
        }
        
        
    public String getUserSessionKey()
        {
            
    return userSessionKey;
        }
        
        
    public void setUserSessionKey(String userSessionKey)
        {
            
    this.userSessionKey = userSessionKey;
        }
        
        
    public String getIsCheckLogin()
        {
            
    return isCheckLogin;
        }
        
        
    public void setIsCheckLogin(String isCheckLogin)
        {
            
    this.isCheckLogin = isCheckLogin;
        }
        
    }


    posted on 2008-10-28 09:26 HUIKK 閱讀(1774) 評論(0)  編輯  收藏 所屬分類: Struts
    主站蜘蛛池模板: 亚洲AV无码国产剧情| 国产亚洲精品欧洲在线观看| 中文字幕无码毛片免费看| 亚洲国产精品一区二区第一页免| 亚洲av无码专区首页| 国产成人无码免费视频97| 免费精品久久久久久中文字幕| 免费又黄又硬又爽大片| 一级特黄aaa大片免费看| 国产91精品一区二区麻豆亚洲| 久久久受www免费人成| 亚洲AV日韩AV永久无码绿巨人| 久久免费的精品国产V∧| 亚洲人成高清在线播放| 日韩免费一级毛片| 免费看一级一级人妻片| 中文字幕中韩乱码亚洲大片| 久草免费福利视频| 亚洲免费福利视频| 又黄又爽一线毛片免费观看| www成人免费视频| 自怕偷自怕亚洲精品| 国产免费不卡v片在线观看| 亚洲av日韩av永久无码电影| 亚洲色婷婷综合开心网| 久久免费公开视频| 亚洲色偷偷综合亚洲AV伊人蜜桃| 免费国产真实迷j在线观看| 中文字幕视频免费在线观看| 亚洲精品视频观看| 四虎永久在线精品免费影视 | 亚洲乱码无码永久不卡在线| 久久国产精品一区免费下载| 亚洲精品二三区伊人久久| gogo全球高清大胆亚洲| 日韩电影免费在线观看| 亚洲AV无码一区二区大桥未久| 亚洲精品无码久久千人斩| 国产人在线成免费视频| 国产国产人免费人成成免视频| 亚洲神级电影国语版|