Spring MVC項目中頁面重定向一般使用return "redirect:/other/controller/";即可。
而Spring Boot當我們使用了@RestController注解,上述寫法只能返回字符串,解決方法如下:
@RestController public class LoginController { @RequestMapping("/logout") void handleLogout(HttpServletResponse response) throws IOException { response.sendRedirect("some-url"); } }