登录后返回登录前的页面

首先将一个变量currentURL设置为要返回的地址,进入登陆的页面的时候将其用隐藏域

<input type=”hidden”  value=”${currentUrl}” name=”currentUrl”/>保存,登录时,将其又传回登录的方法中,登陆成功就重定向到currentURL保存的地址

 private String currentUrl;
    /**
     * 前往登录界面
     * 
     * @return result的name
     * @since 1.0
     */
    public String toLoginPage() {
        // 得到登陆前的地址,方便登陆后的返回
        if ("index".equals(currentUrl)) {
            this.currentUrl = null;
        } else {
            String URL = getHttpServletRequest().getHeader("Referer");
            String args = getHttpServletRequest().getQueryString();
            if (URL == null) {
                this.currentUrl = null;
            } else {
                if (args != null) {
                    this.currentUrl = URL + "?" + args;
                } else {
                    if (URL.contains("login_toLoginPage") || URL.contains("registe_toRegistePage")) {
                        this.currentUrl = null;
                    } else {
                        this.currentUrl = URL;
                    }
                }
            }
        }
        return "toLoginPage";
  }
  


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值