struts2 interceptor

struts.xml configuration

struts2 interceptor
<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"/>
struts2 interceptor

user-defined interceptor

struts2 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;
    }

}
struts2 interceptor

struts2 interceptor

上一篇:Spring3.0+Hibernate+Atomikos集成构建JTA的分布式事务--解决多数据源跨库事务


下一篇:STL set,mulityset用法