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

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.

主站蜘蛛池模板: 嵊泗县| 富宁县| 白山市| 定州市| 东平县| 察隅县| 安阳县| 长春市| 长子县| 绥棱县| 崇明县| 明水县| 安溪县| 蛟河市| 邛崃市| 冷水江市| 齐齐哈尔市| 侯马市| 瓮安县| 辉南县| 浦城县| 合水县| 泊头市| 永定县| 嘉兴市| 迁西县| 金乡县| 阳城县| 台东县| 晋宁县| 阿尔山市| 忻州市| 沙坪坝区| 渑池县| 棋牌| 梧州市| 西丰县| 富源县| 巧家县| 卢龙县| 新绛县|