这其实就是 获得应用的根url,比如说你的应用的根路径是 http://localhost:8080,那么你列出的代码就是为basePath赋值为 http://localhost:8080
具体点:
1、request.getScheme() 返回协议的名称 http,和后面的"://" 拼起来就成了 http://
2、request.getServerName() 这是获取你的服务器的名称,如果你的应用部署在本机那么其就返回localhost或者127.0.0.1 ,这2个是等价的
3、request.getServerPort() 是你应用使用的端口,比如8080或者80 等等 上面3点的结果拼起来就构成了你应用的根路径或者说是根url

这个是我自己获取程序地址的方法:

request.setAttribute("basePath", request.getScheme() + "://"             + request.getServerName() + ":" + request.getServerPort()             + request.getContextPath() + "/");

basepath的 属性为程序地址

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getSer的更多相关文章

  1. String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";作用!!!!!

    <%String path = request.getContextPath();String basePath = request.getScheme()+"://"+re ...

  2. String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+pat----------<base>元素有关

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

  3. <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>

    <%String path = request.getContextPath();String basePath = request.getScheme()+"://"+re ...

  4. jsp中的<% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>

    <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+ ...

  5. jsp页面String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";作用!!!!!

    转自:https://blog.csdn.net/kiwangruikyo/article/details/81130311 <%String path = request.getContext ...

  6. 关于String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

    关于 String path = request.getContextPath(); String basePath = request.getScheme()+"://"+req ...

  7. basePath = request.getScheme()+"://"+request.getServerName()+":"+r

    basePath = request.getScheme()+"://"+request.getServerName()+":"+r (2014-06-30 1 ...

  8. JSP中的:request.getScheme()+"://"+request.getServerName()+":"+request.getServer

    String path = request.getContextPath();  String basePath = request.getScheme()+"://"+reque ...

  9. request.getScheme()、 request.getServerName() 、 request.getServerPort() 、 request.getContextPath()

    <% String basePath = request.getScheme() + "://" + request.getServerName() + ":&qu ...

随机推荐

  1. 前端中的事件循环eventloop机制

    我们知道 js 是单线程执行的,那么异步的代码 js 是怎么处理的呢?例如下面的代码是如何进行输出的: console.log(1); setTimeout(function() { console. ...

  2. 洛谷P1312 Mayan游戏

    P1312 Mayan游戏 题目描述 Mayan puzzle是最近流行起来的一个游戏.游戏界面是一个 7 行5 列的棋盘,上面堆放着一些方块,方块不能悬空堆放,即方块必须放在最下面一行,或者放在其他 ...

  3. MCP|DYM|Quantitative mass spectrometry to interrogate proteomic heterogeneity in metastatic lung adenocarcinoma and validate a novel somatic mutation CDK12-G879V (利用定量质谱探究转移性肺腺瘤的蛋白质组异质性及验证新体细胞突变)

    文献名:Quantitative mass spectrometry to interrogate proteomic heterogeneity in metastatic lung adenoca ...

  4. SLF4J、Log4J使用记录

    程序中一直在用log4j,之前都没了解过,只知道是打印日志信息的.最近独立新建了几个开发工程,发现slf4j老有冲突,开始关注起来,我用log4j打印日志,与slf4j有毛关系,怎么老冲突呢.网上找了 ...

  5. Orthanc+OHIF DICOM Viewer最佳Dicom解析、在线浏览实践指南(解决方案)

    概念 DICOM identifiers Very importantly, the DICOM standard specifies DICOM tags that allow to index e ...

  6. css3旋转立方体-_-

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  7. $.store.book[?(@.category=='fiction')].category

    表达式1 $.store.book[?(@.category=='fiction')].category json source { "store": { "book&q ...

  8. Spring @CacheEvict 无效。。。。

    使用 此 注解 时...需要 配置 它 的 key .... @CacheEvict(value = { "adminFunc", "groupFunc" }, ...

  9. uoj455 【UER #8】雪灾与外卖

    http://uoj.ac/problem/455 题解: https://blog.csdn.net/litble/article/details/88410435 https://www.mina ...

  10. (转)CentOS 7系统详细开机启动流程和关机流程

    CentOS 7系统详细开机启动流程和关机流程 原文:http://blog.csdn.net/yuesichiu/article/details/51350654 名称 bootup - 系统启动流 ...