Java getRealPath("/")与getContextPath()区别详细分析
这篇文章主要介绍了Java getRealPath("/")与getContextPath()区别详细分析,本篇文章通过简要的案例,讲解了该项技术的了解与使用,以下就是详细内容,需要的朋友可以参考下
">jsp中的<% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%...
pageContext.request.contextPath 和 request.getContextPath()
作用是取出部署的应用程序名,这样不管如何部署,所用路径都是正确的。El表达式的写法:${pageContext.request.contextPath}jsp的写法:<%=request.getContextPath()%>pageContext.request.contextPath和...
request.getContextPath是为了解决相对路径的问题,可返回站点的根路径
假定你的webapplication名称为news,你在浏览器中输入请求路径:http://localhost:8080/news/main/list.jsp则执行下面向行代码后打印出如下结果:1、System.out.println(request.getContextPath());打印结果:/...