我对Java很糟糕。我已经尝试过寻找这个,但是尽管我确信它很容易找到答案却出奇地难。
我的网址是: https ://www.example.com/path/to/file.jsp
我只需要打印它。就这么简单。就像是:
<a href="http://www.foo.com?TARGET=https://www.example.com/path/to/file.jsp">Go</a>
我试过了...
(request.getRequestURL()).toString();
...但它提供了http://www.example.com/path/to/file.jsp - 我需要 HTTPS
我试过了...
<c:set var="req" value="${pageContext.request}" />
<c:set var="targetURL" value="${req.scheme}://${req.serverName}${req.contextPath}" />
...但它给出了https://www.example.com/
地址栏中的内容永远是正确的。我只需要它具有正确的协议和完整路径。