Spring MVC Redirect to HTTPs site after successful post form
We would like to redirect user after a successful post to secure pages.
@RequestMapping(value="/myapp", method=POST)
public String processForm(Formbean formb开发者_开发知识库ean){
// redirect to https ??????
return "redirect:/secure";
}
Is there any easy way to make it without writing full redirection url?
you can check out RedirectView and the contextRelative parameter in the Spring API Docs:
http://static.springsource.org/spring/docs/2.0.x/api/org/springframework/web/servlet/view/RedirectView.html
hope that helped...
Not too sure you can do that without specifying the entire url in the redirect string.
Perhaps its best to add a security constraint for that url in your web.xml setting the transport-guarantee to CONFIDENTIAL. If your servlet container is setup correctly then that should be all you need to get it to do the automatic redirect for you.
<security-constraint>
<web-resource-collection>
<web-resource-name>Secure page</web-resource-name>
<url-pattern>/securePage.html</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
精彩评论