小编Dan*_*ott的帖子

拦截器的invocation.invoke()之后没有填充Struts 2动作变量

我的问题是,在使用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();
    }
}
Run Code Online (Sandbox Code Playgroud)

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 …
Run Code Online (Sandbox Code Playgroud)

java variables action struts2 interceptor

5
推荐指数
1
解决办法
3821
查看次数

标签 统计

action ×1

interceptor ×1

java ×1

struts2 ×1

variables ×1