Spring MVC "redirect:" prefix always redirects to http -- how do I make it stay on https? -
I solved this myself, but I spent so long exploring such a simple solution, I figured it here Were worth documenting.
I set up a specific Spring 3 MVC with an InternalResourceViewResolver:
& Lt; Property name = "prefix" value = "/" /> & Lt; Property name = "suffix" value = ".jsp" /> & Lt; / Bean & gt;
I have a very simple handler method in my controller, but I have made it even easier for this example:
@RequestMapping (" / Groups ") public string selection group () {" redirection: / "; }
The problem is, if I am browsing on https://my.domain.com/groups
, then I'll see it at http: // Ends with my.domain.com /
redirect (in reality my load-balance https redirects all http requests, but this only causes many browser alerts of type "You are leaving / a secure connection "People are asking to turn on such notifications.)
The question is, when the use of any original request C is, then get someone to reading the https to spring?
The short answer is, on the wrong, the redirectHttp10Compatible property set of InternalResourceViewResolver:
& Lt; Beam id = "viewResolver" class = "org.springframework.web.servlet.view.InternalResourceViewResolver" & gt; & Lt; Property Name = "View Class" Value = "org.springframework.web.servlet.view.JstlView" /> & Lt; Property name = "prefix" value = "/" /> & Lt; Property name = "suffix" value = ".jsp" /> & Lt; Property name = "redirect HTTP 10 compatible" value = "wrong" /> & Lt; / Bean & gt;
You can do this instead of requesting a copy, instead of seeing your handler method return to the string, and create RedirectView yourself, and setHttp10Compatible (false) By calling
.
(It turns out that the culprit is HttpServletResponse.sendRedirect, which uses redirected HTTP 1.0 for relevant redirects, but not otherwise.I think this means that it is implemented on the implementation of your topmost container Dependent? I saw problem in both Tomcat and JT.)
Comments
Post a Comment