关于request.getServletPort()获取访问地址的说明
2016-03-10 09:58
609 查看
1:代码片段:
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
<base href="<%=basePath%>">
2、复习一下request 的常用方法:
request.getSchema()可以返回当前页面使用的协议,http 或是 https;
request.getServerName()可以返回当前页面所在的服务器的名字;
request.getServerPort()可以返回当前页面所在的服务器使用的端口,就是80;
request.getContextPath()可以返回当前页面所在的应用的名字;
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
<base href="<%=basePath%>">
2、复习一下request 的常用方法:
request.getSchema()可以返回当前页面使用的协议,http 或是 https;
request.getServerName()可以返回当前页面所在的服务器的名字;
request.getServerPort()可以返回当前页面所在的服务器使用的端口,就是80;
request.getContextPath()可以返回当前页面所在的应用的名字;
相关文章推荐
- string拼接和StringBuilder性能对比
- Explicit Interface Implementation (C# Programming Guide)
- String,StringBuilder,StringBuffer的区别
- [LeetCode]62. Unique Paths
- Interfaces (C# Programming Guide)
- 修改UIcontrollerTableView某一行的高度
- KVC中setValuesForKeysWithDictionary:
- LeetCode Distinct Subsequences
- 背水一战 Windows 10 (2) - UI: 概述, 启动屏幕, 屏幕方向
- build st-crowd
- MathType requires a newer version of MT Extra等MathType问题的不兼容性解决方案
- UIWindow 实现遮盖导航条的蒙版
- Mysql 连接数据库超时设置autoReconnect=true
- @RequestParam @RequestBody @PathVariable 等参数绑定注解详解
- jquer “$” 扩展(笔记)
- lintcode-easy-Unique Paths II
- lintcode-easy-Unique Paths
- 非UI线程可不可以更新UI(二)
- 《EasyUI》——给DataGrid动态绑定表头和数据,实现表头与数据的真正解耦
- UITextField - 输入框