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

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.

主站蜘蛛池模板: 玛纳斯县| 西华县| 双鸭山市| 招远市| 阳山县| 平潭县| 丰台区| 元氏县| 板桥市| 云浮市| 日喀则市| 大英县| 沽源县| 喜德县| 扎赉特旗| 舟山市| 逊克县| 舞阳县| 大英县| 宾川县| 内丘县| 萍乡市| 石河子市| 娄底市| 和平县| 天门市| 曲松县| 合肥市| 申扎县| 伊宁市| 屏山县| 松滋市| 铜鼓县| 平乡县| 余庆县| 普陀区| 石渠县| 宜城市| 武城县| 林州市| 绥芬河市|