3
我想在春天301重定向,所以這裏的一段代碼,我用HTTP重定向:301(永久)與302(臨時)春季
@RequestMapping(value = { "/devices" } , method = RequestMethod.GET)
private String initGetForm(@ModelAttribute("searchForm") final SearchForm searchForm,
BindingResult result,
HttpServletRequest request,
HttpServletResponse response,
Model model, Locale locale) throws Exception {
String newUrl = "/devices/en";
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
response.setHeader("Location", newUrl);
response.setHeader("Connection", "close");
return "redirect:" + newUrl;
}
但檢查IE開發工具我得到了這個狀態302移動暫時!
因爲你正在返回'redirect:+ newUrl',這基本上呈現你在做那些無用之前所做的所有事情。不要返回任何東西,返回void。 –