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

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.

主站蜘蛛池模板: 共和县| 泰和县| 彩票| 广昌县| 平阴县| 和静县| 大兴区| 五指山市| 平和县| 高邑县| 泰安市| 酉阳| 中牟县| 东兰县| 永清县| 勃利县| 郯城县| 甘肃省| 永善县| 连云港市| 赣榆县| 壤塘县| 大城县| 红安县| 武胜县| 凤山市| 元朗区| 文登市| 呼和浩特市| 永昌县| 连山| 道真| 武山县| 偏关县| 通许县| 龙游县| 吕梁市| 昌宁县| 汝州市| 涿鹿县| 富阳市|