zoukankan      html  css  js  c++  java
  • struts2 interceptor

    struts.xml configuration

    <interceptors>
    <interceptor name="AuthenticationInterception" class="com.vincent.faceLook.interceptor.AuthenticationInterception"/>
    <interceptor-stack name="oaInterceptorStack">
    <interceptor-ref name="AuthenticationInterception"/>
    <interceptor-ref name="defaultStack"/>
    </interceptor-stack>
    </interceptors>
    <default-interceptor-ref name="oaInterceptorStack"/>

    user-defined interceptor

    package com.vincnet.jusns.interceptor;
    
    import com.opensymphony.xwork2.ActionInvocation;
    import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
    import com.vincnet.jusns.entity.User;
    
    public class AuthenticationInterception extends AbstractInterceptor {
    
        @Override
        public String intercept(ActionInvocation ai) throws Exception {
            // TODO Auto-generated method stub
            //String interceptInfo = "concent";
            String interceptInfo = null;
            User user = (User) ai.getInvocationContext().getSession()
                    .get("currentUser");
            if (user != null) {
                ai.invoke();
            } else {
                String method = ai.getProxy().getMethod();
                if("login".equals(method)){
                    ai.invoke();
                }else{
                    interceptInfo = "user not login";
                }
            }
            return interceptInfo;
        }
    
    }
  • 相关阅读:
    C# 微信 生活助手 空气质量 天气预报等 效果展示 数据抓取 (二)
    2014年个人总结
    是去是留?这是个问题
    电信限制ip的解决方案
    机械学习
    mac-mysql
    如何使用代码生成工具
    如何使用自定义表单和自定义流程
    test
    编程小问题001
  • 原文地址:https://www.cnblogs.com/BrightMoon/p/3533347.html
Copyright © 2011-2022 走看看