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:\...\ProjectXXX\WebContent"/>

posted @ 2014-02-07 14:12  rldts  阅读(1494)  评论(0编辑  收藏  举报