我们希望在成功发布帖子后将用户重定向到安全页面。
@RequestMapping(value="/myapp", method=POST)
public String processForm(Formbean formbean){
// redirect to https ??????
return "redirect:/secure";
}
有没有简单的方法可以在没有编写完全重定向网址的情况下完成它?
答案 0 :(得分:2)
您可以在Spring API Docs中查看RedirectView和contextRelative参数:
希望有所帮助......
答案 1 :(得分:0)
如果不在重定向字符串中指定整个网址,就不太清楚。
也许最好在web.xml中为该URL添加安全约束,将transport-guarantee设置为CONFIDENTIAL。如果您的servlet容器设置正确,那么您应该只需要它来为您执行自动重定向。
<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>