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.具体点: ...
随机推荐
- 将Komodo Edit打造成Python开发的IDE
Komodo Edit 支持Python 界面清爽, 将Komodo Edit 设置成Python的IDE,具体操作方法如下: 先添加自定义命令. 再设置命令行参数 设置高级选项 设置快捷键 完成.
- Altium Designer使用5:AD18的DXP在什么地方?
1.在顶上的菜单栏右击
- POJ 3484 二分
Showstopper Description Data-mining huge data sets can be a painful and long lasting process if we a ...
- 24-webhost的配置
1-新建asp.net core空项目 2-创建setting.json文件 3- 配制Progrom类中CreateWebHostBuilder 4-获取配置的文件 5-显示结果
- js柱状图
<!doctype html><html lang="en"><head><script type="text/javascri ...
- [WC2002][洛谷P1578]奶牛浴场
洛谷题解里那个人可真是话多呢. 题目描述 由于John建造了牛场围栏,激起了奶牛的愤怒,奶牛的产奶量急剧减少.为了讨好奶牛,John决定在牛场中建造一个大型浴场.但是John的奶牛有一个奇怪的习惯,每 ...
- laravel5.5用户认证源码分析
目录 1. 生成相关文件和配置 2. 分析路由文件 3. 以登陆开始为例,分析auth到底是怎么工作的 3.1 分析登录文件 3.2 分析门面Auth. 1. 生成相关文件和配置 快速生成命令 php ...
- 干货100+ 最超全的web开发工具和资源大集合
干货100+ 最超全的web开发工具和资源大集合 作为Web开发者,这是好的时代,也是坏的时代.Web开发技术也在不断变化.虽然很令人兴奋,但是这也意味着Web开发人员需要要积极主动的学习新技术和 ...
- Git从入门到熟练
Git的特性 1. 分布式版本控制 集中式VS分布式 保存更新时的文件快照而非差异 (快照 :是文件系统中的概念或者技术:来自照相领域的概念,是指特定时间点的一个状态) 其他系统在每个版本中记录着各个 ...
- 【Java】Java JDK 安装及环境配置
安装包下载: Java Platform (JDK) 11 https://www.oracle.com/technetwork/java/javase/downloads/index.html 安装 ...