Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 用户登录struts 2后如何返回到pre页面?_Java_Struts2 - Fatal编程技术网

Java 用户登录struts 2后如何返回到pre页面?

Java 用户登录struts 2后如何返回到pre页面?,java,struts2,Java,Struts2,这是我的想法,但我不知道为什么不起作用: 首先,我创建了一个拦截器来验证当前用户是否登录: public class LoginInterceptor extends AbstractInterceptor { @Override public String intercept(ActionInvocation ai) throws Exception { // check http sessoin ... if(notLogin) {

这是我的想法,但我不知道为什么不起作用:

首先,我创建了一个拦截器来验证当前用户是否登录:

public class LoginInterceptor extends AbstractInterceptor {
    @Override
    public String intercept(ActionInvocation ai) throws Exception {
        // check http sessoin ...
        if(notLogin) {
            return Action.LOGIN;
        }
        return ai.invoke();
    }
}
然后,我编写了如下配置文件:

<global-results>
    <result name="login" type="redirect">   
        <param name="location">/login</param>
        <param name="referrer">${#request['struts.request_uri']}</param>
    </result>
</global-results>

/登录
${#请求['struts.request_uri']}
但在登录页面上,“referer”参数始终为空,因此我无法使用该参数重定向到用户登录前访问的页面


我怎样才能正确地获取这个“referer”?

@umeshawashi
struts.request.uri
由struts 2在其他页面上自动设置。我通过检查
标记的内容找到它。@umeshawashi
struts.request.uri
在我的拦截器中不可用,因此我必须使用http servlet API获取当前url。谢谢。