href中使用相对路径访问上级目录的方法

项目ProjectXXX目录如下:

WebContent>

  hello.jsp

    Folder1>

      foo.jsp

      Folder2>

        foo2.jsp

在foo.jsp中访问hello.jsp:href="..hello.jsp"

在foo2.jsp中访问hello.jsp:href="....hello.jsp"

当然,也可以直接使用绝对路径:href="/hello.jsp",这个方法对foo.jsp和foo2.jsp都适用,前提是你在server.xml中配置类似于<Context path="/ProjectXXX" docBase="D:...ProjectXXXWebContent"/>

原文地址:https://www.cnblogs.com/qrlozte/p/3539458.html