request.getScheme()的使用方法
今天在修改bug时,发现程序使用了 request.getScheme() 。不明白是什么意思,在google 搜索了一下。现在明白了。整理如下:
1、request.getScheme() 返回当前链接使用的协议;比如,一般应用返回http;SSL返回https;
2、在程序中的应用如下:
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
3、复习一下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 + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAaMAAABiCAIAAAByNCsGAAARvUlEQVR4nO2d0U/cSJ7H/d/MY/8XPCChjeZhRorWJ20UaRUp93KT3dNFi5RpEbGezFwSsmTYITdcmIW7sFzoYbubAB3SATqE0LAweEiYMBxiIxKFFVmFnGj1y+8eii6Xy1Wm3bRpu/l+ZEV02S6Xf6765ldVdv0MAgCAZsdodAEAACB0oHQAgOYHSgcAaH6gdACA5gdKBwBofqB0AIDmB0oHAGh+oHQAgOYHSgcAaH6gdACA5gdKBwBoflRK92Gzf6D4VEhY+T7X2rfq/ByZbEmm2dbaOfGbzFbJOfZgNTd7vjPTksye7V1ccnaUt+aLv/vDWFsy3dqZu/Rt4c+bRKXnHZ1pnlVLMt2SnOxZ4/lnO+eI6P293nRLMt3Su/xyIi8e3Pb7nFV4R0Sl/HRr0p3Pjfkl/T3v2mv307NfTb2v1WgC//vy/sMf/vPP+X8eWheT54an+zfrkD0AoC7ISre/smiNPBeli2jj+rX0hfRrIWXr9o3x64tlooOXT+bOd4x1zpWJiOjd6N3xs98urX4g+rDZdTPz2xxTk/LS9w8/7n6a2zogKm/NPzm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3riynDd1RfCW1K8OhCCbI9LqFUef4fsBaoJLRQsYkAAAAASUVORK5CYII=" alt="" />
request.getScheme()的使用方法的更多相关文章
- request.getScheme() 使用方法
今天在看代码时,发现程序使用了 request.getScheme() .不明白是什么意思,查了一下.结果整理如下: 1.request.getScheme() 返回当前链接使用的协议:一般应用返回h ...
- request.getScheme() 使用方法(转)
今天在看代码时,发现程序使用了 request.getScheme() .不明白是什么意思,查了一下.结果整理如下: 1.request.getScheme() 返回当前链接使用的协议:一般应用返回h ...
- (转)Nginx SSL+tomcat集群,request.getScheme() 取到https正确的协议
转自http://www.cnblogs.com/interdrp/p/4881785.html 最近在做一个项目, 架构上使用了 Nginx +tomcat 集群, 且nginx下配置了SSL,to ...
- Request中的各种方法
前言 Request中方法众多,对于Java Web程序员来说,种种方法都会在工作中常常用到.Request由于不是JDK的一部分,这些方法的用法也没有专门的API可以查,所以在工作中遇到Reques ...
- Nginx SSL+tomcat集群,request.getScheme() 取到https正确的协议
最近在做一个项目, 架构上使用了 Nginx +tomcat 集群, 且nginx下配置了SSL,tomcat no SSL,项目使用https协议 但是,明明是https url请求,发现 log里 ...
- request.getScheme() 取到https正确的协议(转载)
最近在做一个项目, 架构上使用了 Nginx +tomcat 集群, 且nginx下配置了SSL,tomcat no SSL,项目使用https协议 但是,明明是https url请求,发现 log里 ...
- struts2 action中获取request session application的方法
共四种方式: 其中前两种得到的是Map<String,Object> 后两种得到的才是真正的request对象 而Map就是把request对象中的属性取出做成了键值对而已. [方法一] ...
- JSP中的:request.getScheme()+"://"+request.getServerName()+":"+request.getServer
String path = request.getContextPath(); String basePath = request.getScheme()+"://"+reque ...
- String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getSer
这其实就是 获得应用的根url,比如说你的应用的根路径是 http://localhost:8080,那么你列出的代码就是为basePath赋值为 http://localhost:8080.具体点: ...
随机推荐
- 使用postMan测试insert或者update接口
URL : http://localhost:8099/orderVoice/updateAgentLogin?access_token=7f10e803-f886-47df-b3dc-9ed307d ...
- 用Go实现RabbitMQ消息收发
// amqp.Dial accepts a string in the AMQP URI format and returns a new Connection over TCP using Pla ...
- python-3高级特征
1-切片 L = ["qinzb",'fengyong','bingyan'] L[0:3] #截取从索引0开始到索引3结束(不包含索引3) L[:3] #如果索引是从0开始则可省 ...
- WPF点击不同界面上的按钮实现界面切换
原文:WPF点击不同界面上的按钮实现界面切换 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/qq_29844879/article/details/ ...
- Android stadio 自定义debug release keystore
1.添加siggnig name 随意,不过按我写的就可以了.设置完成之后,你的build.grade就会多出来一些: android { signingConfigs { signingConfig ...
- mybatis和redis整合 log4j打印sql语句
首先,需要在项目中引进jedis-2.8.1.jar包,在pom.xml里加上 <dependency> <groupId>redis.clients</groupId& ...
- laravel5.5事件系统
目录 1 注册事件和监听器 2 定义事件 3 定义监听器 4 分发事件 更多使用方法 1. 可以手动注册事件 2. 事件监听器中调用队列 3.事件订阅者 1 注册事件和监听器 1.修改EventSer ...
- python学习笔记十一:操作mysql
一.安装MySQL-python # yum install -y MySQL-python 二.打开数据库连接 #!/usr/bin/python import MySQLdb conn = MyS ...
- Monkey、Monkeyrunner之间的区别
Monkey.Monkeyrunner之间的区别 一.Monkey Monkey是Android中的一个命令行工具,可以运行在模拟器里或实际设备中.它向系统发送伪随机的用户事件流(如按键输入.触摸屏输 ...
- 使用pip命令报You are using pip version 9.0.3, however version 18.0 is available pip版本过期.解决方案
使用pip命令安装或卸载第三方库时报You are using pip version 9.0.3, however version 18.0 is available.错误,一般情况下是pip版本过 ...