我应该如何在jsp页面中获取根文件夹路径 [英] how should I get root folder path in jsp page

查看:465
本文介绍了我应该如何在jsp页面中获取根文件夹路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检索web应用程序的根路径,然后我想追加链接到根路径。
我尝试了request.context,但它返回http:// localhost:8080 / webapp / web-inf。

例如,我的根文件夹路径是

  path = http:// localhost:8080 / webapp / 

并且我想追加剩余的链接到这个路径

  helpPath = /help/page/help.htm 


< a href =$ {path} + $ {helpPath}target =_ blank> name< / a>

任何帮助或指针真的很感谢。

解决方案

 <%= request.getContextPath()%> 

会为您提供您的应用程序的根路径,因此在您的情况下它将会是 http:// localhost:8080 / webapp



根据评论

 <%= request.getContextPath()%> /help/page/help.htm 

会给你你的页面$ / b>

I want to retrieve root path of webapplication, then I want to append link to root path. I tried request.context but it returns "http://localhost:8080/webapp/web-inf".

For example my root folder path is

path  =  http://localhost:8080/webapp/

and I want to append remaining link to this path

helpPath= /help/page/help.htm


<a  href="${path} + ${helpPath}" target="_blank">name</a>

Any help or pointer really appreciated.

解决方案

<%=request.getContextPath()%> 

will give you the rootpath of your application so in your case it will be http://localhost:8080/webapp

As per comment:

<%=request.getContextPath()%>/help/page/help.htm 

will give you your page

这篇关于我应该如何在jsp页面中获取根文件夹路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆