zoukankan      html  css  js  c++  java
  • JSP 12: 服务器端路径的问题

    <1>  区分客户端和服务器端路径

    一般可以在浏览器中(inspect -> html)显示出来的为客户端路径,

    无法在浏览器中显示的路径为服务器端路径

    <2>  测试服务器端路径(相对路径)

    在path.jsp中:

      <body>
        <h1>这是一个h1标签!!</h1>
        <a href="<%=request.getContextPath() %>/test1.jsp">从path.jsp进入test1</a><br/> 
        <jsp:include page="footer.jsp"></jsp:include>
      </body>

    效果:

     能看到网站的脚, 说明路径正确

    <3>  从别的页面跳转过来

     脚没有丢失 (服务器端路径很少出问题)

    <4>  测试服务器端路径(绝对路径)

     

    在path.jsp中:

      <body>
        <h1>这是一个h1标签!!</h1>
        <a href="<%=request.getContextPath() %>/test1.jsp">从path.jsp进入test1</a><br/> 
        <jsp:include page="/footer.jsp"></jsp:include>
      </body>

    客户端绝对路径的root:  http://localhost:8080/

    服务器端绝对路径的root:    http://localhost:8080/项目名(自动添加)/

    <5>  

    从习惯上, 我们更常使用绝对路径  

  • 相关阅读:
    LeetCode77. 组合
    LeetCode76. 最小覆盖子串
    LeetCode75. 颜色分类
    LeetCode74. 搜索二维矩阵
    LeetCode73. 矩阵置零
    LeetCode72. 编辑距离
    MySQL数据库基础知识点
    程序开发必知必会的MySQL基本命令行操作
    程序开发必知必会的Mysql数据库——初识
    初识HTML
  • 原文地址:https://www.cnblogs.com/JasperZhao/p/13507383.html
Copyright © 2011-2022 走看看