对于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

相关文章:

  • 2021-12-11
  • 2021-05-26
  • 2022-12-23
  • 2021-11-07
  • 2021-07-30
  • 2021-04-01
  • 2022-12-23
  • 2021-09-15
猜你喜欢
  • 2021-11-25
  • 2021-08-04
  • 2022-12-23
  • 2021-05-18
  • 2021-08-21
  • 2021-06-29
  • 2021-06-18
相关资源
相似解决方案