官术网_书友最值得收藏!

Customizing application error pages

Every application has a chance of encountering an error, even if it is an extremely robust application. So, designing custom error pages is important for any enterprise application. Spring Boot applications provide a default error page. You can see one in the following screenshot:

But if you want to use a custom error page for a given status code, you can add a file to the /error folder. You can create a custom error page by using static HTML, FreeMarker, Velocity, Thymeleaf, JSP, and so on. The name of the file should be the exact status code or a series mask.

Let's see the following image to map 404 to a static HTML file; your folder structure would be as follows:

As you can see, I have added a custom 404 error page (static error page 404.html) under the /resource/public/error directory; see the following output from the error page:

As you can see, Spring Boot now displays a custom error page instead of the default WhiteLabel error page as part of auto-configuration.

主站蜘蛛池模板: 墨江| 五家渠市| 台州市| 长沙市| 重庆市| 乐平市| 中阳县| 青川县| 阿克苏市| 长沙县| 松潘县| 普宁市| 大英县| 平顶山市| 金秀| 临夏市| 湘潭县| 六安市| 安吉县| 顺平县| 梅州市| 光山县| 永德县| 河源市| 确山县| 大同县| 昌乐县| 兴业县| 柘城县| 东源县| 抚远县| 磴口县| 交城县| 常德市| 佛学| 图片| 蚌埠市| 景洪市| 江川县| 石泉县| 涟源市|