通过实现ErrorPageRegistrar接口,重写registerErrorPages方法配置错误页面跳转:

springboot错误页面放在templates下无法跳转

如果404.html错误页面放在templates包下,需要配置controller进行访问跳转

springboot错误页面放在templates下无法跳转

如果放在static包下,可以直接通过页面访问到。

在springboot项目中默认访问路径是static文件夹和template文件夹,static文件夹下的资源可以通过浏览器直接访问(如:localhost:8080/index.html,如有文件夹输入正确路径即可 如:localhost:8080/image/abc.jpg),而template文件夹下的页面需要在controller中跳转进行访问。在controller中如果直接return页面的名称那么默认从template文件夹中去寻找对应的页面

相关文章:

  • 2021-09-20
  • 2022-12-23
  • 2021-06-09
  • 2021-10-31
  • 2022-01-05
  • 2022-12-23
  • 2022-12-23
  • 2021-05-23
猜你喜欢
  • 2021-06-28
  • 2021-07-13
  • 2021-12-13
  • 2022-12-23
  • 2021-05-23
  • 2022-12-23
  • 2021-05-04
相关资源
相似解决方案