對於thymeleaf中的重定向的跳轉時,比如下面的登出注銷之后跳轉到首頁
@RequestMapping("/usr/logout")
public String logout(HttpSession session) {
session.invalidate();
return "redirect:/index.html";
}
因為我在springboot的配置文件中加上了下面這一行配置,更改了默認的contex-path,
server.servlet.context-path=/luwanglin
我以為上述的controller跳轉邏輯會出錯,但是實際上並沒有
thymeleaf中會自動加上當前的 context-path
,所以實際產生的請求路徑為 http://localhost:8080/luwanglin/index.html
,這個和SpringMVC中的就有些區別了,詳情見上一篇文章