//获取是http 还是 https,如果有通过nginx就行转发,记得配置带上sceme信息
String scheme = request.getScheme();
System.out.println("scheme = " + scheme);
//获取域名
String serverName = request.getServerName();
System.out.println("serverName = " + serverName);
//组装成基础url
String basePath = scheme + "://" + request.getServerName() + "/";
System.out.println("basePath = " + basePath);
效果 basePath = http://ssvass-uat.longfor.com/
本文介绍了如何通过Java获取请求的协议(scheme)和服务器名(serverName),并组合成基础URL。重点在于如何处理通过Nginx的转发,确保URL包含完整的SCHEME信息。
2994

被折叠的 条评论
为什么被折叠?



