SpringBoot自定义错误页面,SpringBoot 40四、500错误提示页面html
SpringBoot 4xx.html、5xx.html错误提示页面spring
================================mvc
©Copyright 蕃薯耀 2018年3月29日app
http://www.cnblogs.com/fanshuyao/spa
附件&源码下载见:http://fanshuyao.iteye.com/blog/2414828code
1、SpringBoot 40四、500错误提示页面htm
一、在使用ThymeLeaf模板时,springBoot会自动到blog
文件夹下寻找404.htm、500.html的错误提示页面资源
错误提示页面的命名规则就是:错误码.html,如404是404.html,500是500.html源码
二、若是没有使用ThymeLeaf模板时,SpringBoot会到静态资源文件夹寻找404.htm、500.html的错误提示页面,命名同上。
SpringBoot默认的静态资源文件有:
这个是生成SpringBoot项目直接有的。
还有3个隐藏的静态资源文件夹:
即Springboot中默认的静态资源路径有4个,分别是:
classpath:/METAINF/resources/
,
classpath:/resources/
,
classpath:/static/
,
classpath:/public/
优先级顺序为:META-INF/resources > resources > static > public
能够经过修改application.properties文件中的spring.mvc.static-path-pattern属性来修改默认的映射**,配置以下:
2、SpringBoot 4xx.html、5xx.html错误提示页面
错误代码的类型不少,如400、40三、404等等,若是按照上面的方法,须要添加不少页面而
SpringBoot提供了通用的命名方式,就是使用4xx.html、5xx.html命名,如:
4xx.html表示能匹配到400、40三、404……等错误
5xx.html表示能匹配到500、50一、502……等错误
若是404.html和4xx.html同时存在时,优先使用最匹配的,即当发生404错误时,优先匹配404.html页面
================================
©Copyright 蕃薯耀 2018年3月29日
http://www.cnblogs.com/fanshuyao/