版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Qizonghui/article/details/81166668
最近公司需要做https;在浏览器重定向时会从https重新跳到http,所以做了强转;但是在转换过程中使用了替换导致,在苹果浏览器Safari中是不存在的,所以强转后会出现httpss;
判断请求协议:
1.js获取:
if("https:" == document.location.protocol)
if( location.href.indexOf("https") > -1 )
2.java
String URL = request.getRequestURL().toString();
if(URL.startsWith("https:")){
System.out.println("HTTPS");
}
if("http".equals(request.getScheme()){
System.out.println("HTTP");
}else if ("https".equals(request.getScheme())){
System.out.println("HTTPS");
}