为什么定义的拦截器死活都进不去!各位大虾看看吧!~~struts2的~~

拦截器的配置:

<interceptors>
        <interceptor name="authority"
            class="com.softeem.assurance.interceptor.AuthorityInterceptor ">
        </interceptor>
        <interceptor-stack name="myInterceptor">
            <interceptor-ref name="defaultStack"></interceptor-ref>
            <interceptor-ref name="authority" ></interceptor-ref>
        </interceptor-stack>
</interceptors>

    <default-interceptor-ref name="authority"></default-interceptor-ref>

    <global-results>
             <result name="login">/login.jsp</result>
    </global-results>

    <action name="user*"
        class="com.softeem.assurance.user.action.UserAction" method="{1}">
        <!-- 
        <result name="loginsuccess" type="redirect">userFindRole.action</result>
        <result name="loginfailure">/login.jsp</result>
         -->
        <interceptor-ref name="authority"></interceptor-ref>        
        <result name="failure">/login.jsp</result>
        <result name="baogao">/baogao.jsp</result>
        <result name="success">/main.jsp</result>
        <result name="listsuccess">/tab/userList.jsp</result>
        <result name="findByNameSuccess">/tab/userList.jsp</result>
        <result name="findByRoleSuccess">/tab/userList.jsp</result>
        <result name="userDeleteSuccess">userList.action</result>
        <result name="preSuccess">/tab/userAdd.jsp</result>
        <result name="addSuccess" type="redirect">userList.action</result>
        <result name="preModifySuccess">/tab/userModify.jsp</result>
        <result name="updateSuccess" type="redirect">userList.action</result>   
    </action>

</package>

拦截器代码:

public String intercept(ActionInvocation arg0) throws Exception {
System.out.println("interceptor: ");
ActionContext ac = arg0.getInvocationContext();
Object obj = ac.getSession().get("user");
if(obj != null){
return arg0.invoke();
}else{

        return "login";
    }
}

死活都输不出来我想要的内容


class="com.softeem.assurance.interceptor.AuthorityInterceptor ">





你把拦截器栈配错了,当然取不到值

我测试过,拦截器已经调用,你想要的内容是什么?

那奇怪了,你设置断点跟踪一下,看你的请求是否进入了Struts2,是否进入了拦截器。在FilterDispather的doFilter设断点。

改成这样试试
[code="java"]

[/code]

[quote]
貌似没有这玩意
[/quote]
什么意思?你开发总会用个IDE吧,我一般就用Eclipse,当然有调试部分了。

进入登录判断前先这样
Object action = ai.getAction();
if (action instanceOf LoginAction || action instanceOf RegisterAction) {
return ai.invoke();
}