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

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

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

    隨筆-59  評論-31  文章-0  trackbacks-0
    1.自定義攔截器繼承AbstractInterceptor,重寫public String intercept(ActionInvocation invocation)方法。
    intercept方法有ActionInvocation對象,可以獲取當前的Action請求。
    public class AuthorityInterceptor extends AbstractInterceptor {
        private static final long serialVersionUID = 1L; 
        private Logger LOG = Logger.getLogger(AuthorityInterceptor.class.getName()); 
        
        private AuthorityUtil authorityUtil;
        
        public String intercept(ActionInvocation invocation) throws Exception {
            if (authorityUtil == null) {
                authorityUtil = new AuthorityUtil();
            }
            
            //獲取當前用戶所有的權限
            List<OperatorPurviewDO> operatorPurviews = getCurrentOperatorPurviews();
            
            //獲取當前操作的url
            String currentUrl = getCurrentUrl(); 
            
             //如果是超級管理員或有當前url的權限,那么直接返回。
            if (OperatorUtil.getIsSuperAdmin() ||(OperatorUtil.getLoginName()!=null&&authorityUtil.checkUrl(operatorPurviews, currentUrl))){
                 return invocation.invoke();
            }
             
            if (!OperatorUtil.getIsSuperAdmin()&&operatorPurviews.size()==0) {
                LOG.info("此用戶:" + OperatorUtil.getLoginName() + " 沒有任何角色,沒有權限執行任何功能"); 
                return "loginErr"; 
            }   
                return "authorityErr";
        }

    2.struts2.xml 配置interceptor

      2.1 定義自定義攔截器
    <interceptor name="authorityInterceptor" class="com.wasu.eis.authority.AuthorityInterceptor" /> 
      2.2 加上struts2默認攔截器,形成攔截器棧
                <interceptor-stack name="eisManagerBasicStack">
                    <interceptor-ref name="exception"/>
                    <interceptor-ref name="alias"/>
                    <interceptor-ref name="servletConfig"/>
                    <interceptor-ref name="prepare"/>
                    <interceptor-ref name="i18n"/>
                    <interceptor-ref name="chain"/>
                    <interceptor-ref name="debugging"/>
                    <interceptor-ref name="profiling"/>
                    <interceptor-ref name="scopedModelDriven"/>
                    <interceptor-ref name="modelDriven"/>
                    <interceptor-ref name="checkbox"/>
                    <interceptor-ref name="staticParams"/>
                    <interceptor-ref name ="fileUploadStack" /> 
                    <interceptor-ref name="params">
                      <param name="excludeParams">dojo\..*</param>
                    </interceptor-ref>
                    <interceptor-ref name="conversionError"/>
                    <interceptor-ref name="validation">
                        <param name="excludeMethods">input,back,cancel,browse</param>
                    </interceptor-ref>
                    <interceptor-ref name="workflow">
                        <param name="excludeMethods">input,back,cancel,browse</param>
                    </interceptor-ref>
                </interceptor-stack>
                
                <interceptor-stack name="authorityInterceptorStack">
                    <interceptor-ref name="authorityInterceptor" />
                    <interceptor-ref name="eisManagerBasicStack" />
                </interceptor-stack>

    3.設置為缺省的攔截器

    <default-interceptor-ref name="authorityInterceptorStack"/>
    posted on 2012-01-17 16:35 RoyPayne 閱讀(2756) 評論(0)  編輯  收藏 所屬分類: SSH
    主站蜘蛛池模板: 成人免费av一区二区三区| 一级特黄色毛片免费看| 久久午夜伦鲁片免费无码| 久久国产成人亚洲精品影院| 曰批全过程免费视频观看免费软件| 国内自产拍自a免费毛片| 国产成人精品日本亚洲语音| 青青草国产免费久久久91| 亚洲精品国产综合久久久久紧| 午夜a级成人免费毛片| 亚洲av无码片vr一区二区三区 | 亚洲天堂一区二区| 91精品免费观看| 亚洲一区无码中文字幕乱码| 可以免费看黄的网站| 亚洲乱亚洲乱妇无码| 波多野结衣视频在线免费观看| 西西人体大胆免费视频| 中文字幕不卡亚洲 | 亚洲综合色一区二区三区| 国产一精品一AV一免费| 亚洲天天做日日做天天欢毛片| 2022久久国产精品免费热麻豆| 久久久久亚洲AV无码专区网站| 中文字幕无码毛片免费看| 亚洲AV日韩精品久久久久| 2020久久精品国产免费| 99亚洲男女激情在线观看| 亚洲人色婷婷成人网站在线观看| 日韩精品人妻系列无码专区免费| 亚洲av乱码一区二区三区| 亚洲第一网站男人都懂| 亚洲国产精品精华液| 久久亚洲国产精品123区| 亚洲电影在线免费观看| 国产精品成人亚洲| 亚洲av日韩av不卡在线观看| 麻豆国产VA免费精品高清在线 | 国产一区二区三区亚洲综合| 亚洲中文字幕在线观看| 无码人妻精品中文字幕免费东京热|