Java Struts 2操作变量未在拦截器';s invocation.invoke()

Java Struts 2操作变量未在拦截器';s invocation.invoke(),java,variables,struts2,action,interceptor,Java,Variables,Struts2,Action,Interceptor,我的问题是,在使用invocation.invoke从拦截器触发操作后,没有填充操作的变量。我所知道的是,在使用拦截器之前,它工作正常(从.jsp我提交了一个表单,调用了一个操作,并填充了每个变量) 拦截器类别: public String intercept(ActionInvocation invocation) throws Exception { final ActionContext context = invocation.getInvocationContext();

我的问题是,在使用invocation.invoke从拦截器触发操作后,没有填充操作的变量。我所知道的是,在使用拦截器之前,它工作正常(从.jsp我提交了一个表单,调用了一个操作,并填充了每个变量)

拦截器类别:

public String intercept(ActionInvocation invocation) throws Exception {

    final ActionContext context = invocation.getInvocationContext();
    HttpServletRequest request = (HttpServletRequest) context.get(HTTP_REQUEST);
    HttpSession session = request.getSession(true);
    Object user = session.getAttribute(Constants.USER_HANDLE);

    if (user == null) {
        String signUp = request.getParameter(Constants.SIGN_UP);

        if (!StringUtils.isBlank(loginAttempt)) {
            if (processLoginAttempt(request, session)) {
                return "login-success";
            }
        } else if (!StringUtils.isBlank(signUp)) {
            return invocation.invoke();
        }
        return "login";
    } else {
        return invocation.invoke();
    }
}
Struts XML文件:

<package name="defaultPackage" extends="struts-default">

    <interceptors>
        <interceptor name="login" class="com.spiddan.LoginInterceptor" />
        <interceptor-stack name="defaultStack">
            <interceptor-ref name="login"/>
        </interceptor-stack>
    </interceptors>

    <default-interceptor-ref name="defaultStack"/>
    <default-action-ref name="index"/>

    <global-results>
        <result name="login" type="redirect">/logIn.jsp</result>
        <result name="login-success" type="redirect">index</result>
    </global-results>

    <action name="addUserAction" class="com.spiddan.action.UserAction" method="addUser">
        <result name="input">/logIn.jsp</result>
        <result name="success">/index.jsp</result>
        <result name="error">/error.jsp</result>
    </action>


您在代码中只指定了自定义拦截器,并排除了所有其他Struts2默认拦截器。请尝试以下方法:

<interceptors>
    <interceptor name="login" class="com.spiddan.LoginInterceptor" />
    <interceptor-stack name="defaultStackModified">  <!-- name doesn't override existing defaultStack-->
        <interceptor-ref name="defaultStack"/>       <!-- include the defaultStack this way--> 
        <interceptor-ref name="login"/>
    </interceptor-stack>
</interceptors>

<interceptors>
    <interceptor name="login" class="com.spiddan.LoginInterceptor" />
    <interceptor-stack name="defaultStackModified">  <!-- name doesn't override existing defaultStack-->
        <interceptor-ref name="defaultStack"/>       <!-- include the defaultStack this way--> 
        <interceptor-ref name="login"/>
    </interceptor-stack>
</interceptors>