我正在编写一个代码,其任务是检索请求的URL或完整路径.我写了这段代码:
HttpServletRequest request;//obtained from other functions
String uri = request.getRequestURI();
if (request.getQueryString() != null)
uri += "?" + request.getQueryString();
Run Code Online (Sandbox Code Playgroud)
所以,当我浏览http://google.com?q=abc它是可以的(正确的).但是当我浏览时有问题https://google.com.的价值uri是http://google.com:443google.com:443,这样的程序时,不仅不HTTPS被使用.
并且输出相同request.getRequestURL().toString().
解决办法是什么?