今天在看代码时,发现程序使用了 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()可以返回当前页面所在的应用的名字;
---------------------
转自https://blog.csdn.net/zy18729286306/article/details/21593721

request.getScheme() 使用方法(转)的更多相关文章

  1. request.getScheme() 使用方法

    今天在看代码时,发现程序使用了 request.getScheme() .不明白是什么意思,查了一下.结果整理如下: 1.request.getScheme() 返回当前链接使用的协议:一般应用返回h ...

  2. request.getScheme()的使用方法

    今天在修改bug时,发现程序使用了 request.getScheme() .不明白是什么意思,在google 搜索了一下.现在明白了.整理如下: 1.request.getScheme() 返回当前 ...

  3. (转)Nginx SSL+tomcat集群,request.getScheme() 取到https正确的协议

    转自http://www.cnblogs.com/interdrp/p/4881785.html 最近在做一个项目, 架构上使用了 Nginx +tomcat 集群, 且nginx下配置了SSL,to ...

  4. Nginx SSL+tomcat集群,request.getScheme() 取到https正确的协议

    最近在做一个项目, 架构上使用了 Nginx +tomcat 集群, 且nginx下配置了SSL,tomcat no SSL,项目使用https协议 但是,明明是https url请求,发现 log里 ...

  5. request常用的方法

    request方法综合:-- 返回请求方式:-request.getMethod()-----GET返回URI中的资源名称(位于URL中端口后的资源路径):-request.getRequestURI ...

  6. request.getScheme() 取到https正确的协议(转载)

    最近在做一个项目, 架构上使用了 Nginx +tomcat 集群, 且nginx下配置了SSL,tomcat no SSL,项目使用https协议 但是,明明是https url请求,发现 log里 ...

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

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

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

    这其实就是 获得应用的根url,比如说你的应用的根路径是 http://localhost:8080,那么你列出的代码就是为basePath赋值为 http://localhost:8080.具体点: ...

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

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

随机推荐

  1. Python Docstring 风格和写法学习

    什么是Python Docstring 和Java类似,Python也通过注释形式的Docstring给程序.类.函数等建立文档.通过Docstring建立的文档不仅对人来说有更好的可读性,也能够让I ...

  2. SQL-W3School-高级:SQL LIKE 操作符

    ylbtech-SQL-W3School-高级:SQL LIKE 操作符 1.返回顶部 1. LIKE 操作符用于在 WHERE 子句中搜索列中的指定模式. LIKE 操作符 LIKE 操作符用于在 ...

  3. 各个处理器架构ISA编程指南

    1.Intel官方文档: http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manu ...

  4. springboot和hadoop2.7.7集成开发

    1.本人在腾讯云安装hadoop2.7.7,详细安装请看以前的博客 2.pom.xml文件 <?xml version="1.0" encoding="UTF-8& ...

  5. csv解析框架Windmill的一个demo

    csv文件内容如下,第一行是文件头 解析代码如下: package com.xxx; import lombok.Data; import org.apache.commons.lang3.build ...

  6. CockroachDB学习笔记——[译]The New Stack:遇见CockroachDB,一个弹性SQL数据库

    原文链接:https://www.cockroachlabs.com/blog/the-new-stack-meet-cockroachdb-the-resilient-sql-database/ 原 ...

  7. LODOP中用ADD_PRINT_IMAGE缩放非图片超文本

    LODOP中HTML,URL,带有img标签的IMAGE,TBALE等打印项都属于超文本.关于LODOP中的纯文本和超文本,可查看本博客相关博文:LODOP中的纯文本和超文本打印项 ADD_PRINT ...

  8. 在本地环境(mac)启用https

    前段时间客户一个涉及地理定位功能的页面突然出问题不能正常使用,在修复的过程中发现定位的方法 getCurrentPosition 只能在 https 协议下才能成功调用,这导致我在本地不能调试,每次修 ...

  9. GBDT详解例子

    https://blog.csdn.net/zpalyq110/article/details/79527653

  10. unity3d 触屏多点触控(旋转与缩放)

    unity3d 触屏多点触控(旋转与缩放) /*Touch OrbitProgrammed by: Randal J. Phillips (Caliber Mengsk)Original Creati ...