首页 > 编程语言 > 详细

在jsp中默认写上的一段java代码表示basePath 的路径的具体的意思是什么?

时间:2015-06-01 13:01:54      阅读:557      评论:0      收藏:0      [点我收藏+]

 <%

    String path = request.getContextPath();

    String basePath = request.getScheme() + "://"

           + request.getServerName() + ":" + request.getServerPort()

           + path + "/";

%>

 

request.getScheme();//可以返回当前页面使用的协议,就是“http”

request.getServerName();//可以返回当前页面所在的服务器的名字,其实就是一般的localhost,如果是真的部署在服务器上那就是服务器的地址

request.getServerPort;//返回的是当前页面所在的服务器使用的端口,一般情况下是80端口,(自己的机器测试的话就是8080)

request.getContextPath;//返回当前页面所在的应用程序的路径,

 

这四个拼装起来,就是当前应用的跟路径了。

<a href="<%=basePath %>/luck/initLuck"   target="blank" style="height:56px"><img src="<c:url value=‘/images/sign_action/actionButton.png‘/>" width="161px" height="56px">

 

在jsp中默认写上的一段java代码表示basePath 的路径的具体的意思是什么?

原文:http://www.cnblogs.com/liuhongfeng/p/4543628.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!