request.getScheme() 使用方法
2014-03-20 09:13
218 查看
今天在看代码时,发现程序使用了 request.getScheme() 。不明白是什么意思,查了一下。结果整理如下:
1、request.getScheme() 返回当前链接使用的协议;一般应用返回http;SSL返回https;
2、在程序中的应用如下:
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
<base href="<%=basePath%>">
3、复习一下request 的常用方法:
request.getSchema()可以返回当前页面使用的协议,http 或是 https;
request.getServerName()可以返回当前页面所在的服务器的名字;
request.getServerPort()可以返回当前页面所在的服务器使用的端口,就是80;
request.getContextPath()可以返回当前页面所在的应用的名字;
1、request.getScheme() 返回当前链接使用的协议;一般应用返回http;SSL返回https;
2、在程序中的应用如下:
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
<base href="<%=basePath%>">
3、复习一下request 的常用方法:
request.getSchema()可以返回当前页面使用的协议,http 或是 https;
request.getServerName()可以返回当前页面所在的服务器的名字;
request.getServerPort()可以返回当前页面所在的服务器使用的端口,就是80;
request.getContextPath()可以返回当前页面所在的应用的名字;
相关文章推荐
- request.getscheme()的使用方法!
- request.getScheme()的使用方法
- request.getScheme()的使用方法
- request.getScheme()的使用方法
- request.getScheme()的使用方法
- request.getScheme() 使用方法
- WP7中HttpWebRequest的使用方法之GET方式
- MVC 下 JsonResult 的使用方法(JsonRequestBehavior.AllowGet)
- wp7使用POST请求Asp.net网页时,HttpWebRequest的BeginGetResponse方法抛出NotSupportException异常的解决方法
- 下面的代码示例使用 BeginGetRequestStream 方法对流实例发出异步请求。
- request.getRealPath不推荐使用request.getRealPath("") 这个方法已经不推荐使用了
- request.getParameterMap()使用方法
- smarty模板中使用get、post、request、cookies、session变量的方法
- MVC 下 JsonResult 的使用方法(JsonRequestBehavior.AllowGet)<转>
- eclipse使用ServletActionContext.getRequest总是出错的解決方法
- jQuery的ajax()检验用户名;通过jQuery的load()/get()/post()方法实现;使用XMLHTTPRequest对象来进行AJAX的异步数据交互
- request.getRealPath()方法不推荐使用
- MVC 下 JsonResult 的使用方法(JsonRequestBehavior.AllowGet)【转】
- request.getRealPath不推荐使用request.getRealPath("") 这个方法已经不推荐使用了
- smarty模板中使用get、post、request、cookies、session变量的方法