thymeleaf中的重定向的绝对路径问题

对于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中的就有些区别了,详情见上一篇文章

https://www.cnblogs.com/luckforefforts/p/13642679.html

保持对优秀的热情
原文地址:https://www.cnblogs.com/luckforefforts/p/13892495.html