我想在jsp中将我的页面http://
重定向到https://
。
我有一些代码,但它出现了一些问题。
<%
String req_protocol = request.getProtocol().toLowerCase();
String convertHttps = req_protocol.substring(0, req_protocol.indexOf("/")).toLowerCase();
if(convertHttps.equals("http")){
response.sendRedirect("https://xyz.com/signup/signup.jsp");
}
%>
它给出的错误页面为“无限循环”。
最佳答案
使用request.isSecure()
确定其是 http://
还是 https://
这种转换更适合 Filter
或 Servlet
而不是 jsp
关于java - http转换为https进入无限循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4451259/