> For the complete documentation index, see [llms.txt](https://jack80342.gitbook.io/spring-boot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jack80342.gitbook.io/spring-boot/ix.-how-to-guides/83.-actuator/83.2-customize-the-whitelabel-error-page.md).

# 83.2 自定义WhiteLabel错误页面

Spring Boot安装了一个'whitelabel'错误页面，如果你遇到一个服务器错误（机器客户端消费的是JSON，其他媒体类型则会看到一个具有正确错误码的合乎情理的响应），那就能在客户端浏览器中看到该页面。你可以设置`error.whitelabel.enabled=false`来关闭该功能，但通常你想要添加自己的错误页面来取代whitelabel。确切地说，如何实现取决于你使用的模板技术。例如，你正在使用Thymeleaf，你将添加一个`error.html`模板。如果你正在使用FreeMarker，那你将添加一个`error.ftl`模板。通常，你需要的只是一个名称为`error`的`View`，或一个处理`/error`路径的`@Controller`。除非你替换了一些默认配置，否则你将在你的`ApplicationContext`中找到一个`BeanNameViewResolver`，所以一个名为`error`的`@Bean`可能是完成该操作的一个简单方式，详情可参考[ErrorMvcAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java)。

查看[Error Handling](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-error-handling)章节，了解如何将处理器（handlers）注册到servlet容器中。
