springboot 異常處理 404 500 處理 錯誤頁面

springboot 在 BasicErrorController 類裏實現了默認的錯誤處理。只需要將對應的錯誤提示文件放到 resources/static/error 目錄,支持模糊匹配,如:

static/error/4xx.html
static/error/5xx.html
static/error/404.html
static/error/error.html

在這裏插入圖片描述

運行項目,然後輸入不存在的地址,觸發 404 錯誤。

在這裏插入圖片描述

參考:http://www.fengyunxiao.cn

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章