zoukankan      html  css  js  c++  java
  • java的Page页面中地址处理

    <%
    	String path = request.getContextPath();
    	String basePath = request.getScheme() + "://"
    			+ request.getServerName() + ":" + request.getServerPort()
    			+ path + "/";
    %>
    <head>
      <base href="<%=basePath%>">
    </head>

    1.request.getContentPath() :返回当前页面所在的项目名字(例:/novel)

    2.request.getScheme() :返回当前页面使用的协议,例:http,或https

    3.request.getServerName() :返回当前页面所在的服务器名字,例:本地是localhost

    4.request.getServerPort():返回服务器的端口号:例:8080,80等

    5.<base href="<%=basePath%>">:基链接,该页面的所有链接都会加上这个基链接

    6.<c:set var="ctx" value="${pageContext.request.contextPath }" />获得页面的基路径,有了<bath href="<%basePath%>" >就不用这个了

  • 相关阅读:
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    codevs 2977 二叉堆练习1x
    codevs 2010 求后序遍历x
    二叉树的序遍历x(内含结构体与非结构体版x)
    医院设置x
    求后序遍历x
    [LightOJ1017]Brush (III)(dp)
  • 原文地址:https://www.cnblogs.com/-scl/p/7244143.html
Copyright © 2011-2022 走看看