相关疑难解决方法(0)

在Servlet中获取HTTP和HTTPS请求的完整URL和查询字符串

我正在编写一个代码,其任务是检索请求的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.的价值urihttp://google.com:443google.com:443,这样的程序时,不仅不HTTPS被使用.

并且输出相同request.getRequestURL().toString().

解决办法是什么?

java servlets httprequest

73
推荐指数
2
解决办法
20万
查看次数

标签 统计

httprequest ×1

java ×1

servlets ×1