zoukankan      html  css  js  c++  java
  • jsp中如何取得当前页面完整的URL

    JSP页面
    <% String url = request.getScheme()+"://"+ request.getServerName()+request.getRequestURI()+"?"+request.getQueryString(); %>


    JAVA代码

        String basePath = request.getScheme()+"://"+request.getServerName();
        String    gotoURL = request.getRequestURI();
        
        gotoURL = gotoURL.replaceAll("//", "/");
        if(gotoURL.indexOf("/WEB-INF/jsp/") != -1){
            gotoURL = gotoURL.replace("/WEB-INF/jsp/","/");
            gotoURL = gotoURL.replace(".jsp",".shtm");
        }
        gotoURL = basePath+gotoURL;
        String queryStr = request.getQueryString();
        if(queryStr!=null){
            gotoURL = gotoURL +"?"+queryStr;
        }
        try {
            gotoURL = URLEncoder.encode(gotoURL,"UTF-8");
        } catch (Exception e1) {
            e1.printStackTrace(); 

        } 

  • 相关阅读:
    canvas
    canvas基础
    canvas基础
    面向对象
    函数的原型链
    原型链&Object的一些方法
    普通函数和构造函数
    下载RDO OpenStack RPM
    RHEL7修改swappiness
    2016年新年愿望
  • 原文地址:https://www.cnblogs.com/wuxiang/p/4409262.html
Copyright © 2011-2022 走看看