Skip to content

Commit 89bf2fc

Browse files
committed
Move "Customize the whitelabel Error Page" into Spring MVC howto
Closes gh-41624
1 parent 5754be3 commit 89bf2fc

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

spring-boot-project/spring-boot-docs/src/docs/antora/modules/ROOT/pages/redirect.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@
329329
* xref:gradle-plugin:running.adoc#running-your-application.using-a-test-main-class[gradle-plugin#running-your-application.using-a-test-main-class]
330330
* xref:how-to:actuator.adoc#howto.actuator[#howto.actuator]
331331
* xref:how-to:actuator.adoc#howto.actuator.change-http-port-or-address[#howto.actuator.change-http-port-or-address]
332-
* xref:how-to:actuator.adoc#howto.actuator.customize-whitelabel-error-page[#howto.actuator.customize-whitelabel-error-page]
333332
* xref:how-to:actuator.adoc#howto.actuator.customizing-sanitization[#howto.actuator.customizing-sanitization]
334333
* xref:how-to:actuator.adoc#howto.actuator.map-health-indicators-to-metrics[#howto.actuator.map-health-indicators-to-metrics]
335334
* xref:how-to:aot.adoc#howto.aot[#howto.aot]
@@ -435,6 +434,7 @@
435434
* xref:how-to:spring-mvc.adoc#howto.spring-mvc.customize-jackson-objectmapper[#howto.spring-mvc.customize-jackson-objectmapper]
436435
* xref:how-to:spring-mvc.adoc#howto.spring-mvc.customize-responsebody-rendering[#howto.spring-mvc.customize-responsebody-rendering]
437436
* xref:how-to:spring-mvc.adoc#howto.spring-mvc.customize-view-resolvers[#howto.spring-mvc.customize-view-resolvers]
437+
* xref:how-to:spring-mvc.adoc#howto.spring-mvc.customize-whitelabel-error-page[#howto.actuator.customize-whitelabel-error-page]
438438
* xref:how-to:spring-mvc.adoc#howto.spring-mvc.multipart-file-uploads[#howto.spring-mvc.multipart-file-uploads]
439439
* xref:how-to:spring-mvc.adoc#howto.spring-mvc.switch-off-default-configuration[#howto.spring-mvc.switch-off-default-configuration]
440440
* xref:how-to:spring-mvc.adoc#howto.spring-mvc.switch-off-dispatcherservlet[#howto.spring-mvc.switch-off-dispatcherservlet]

spring-boot-project/spring-boot-docs/src/docs/antora/modules/how-to/pages/actuator.adoc

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,6 @@ For more detail, see the javadoc:org.springframework.boot.actuate.autoconfigure.
1717

1818

1919

20-
[[howto.actuator.customize-whitelabel-error-page]]
21-
== Customize the '`whitelabel`' Error Page
22-
23-
Spring Boot installs a '`whitelabel`' error page that you see in a browser client if you encounter a server error (machine clients consuming JSON and other media types should see a sensible response with the right error code).
24-
25-
NOTE: Set `server.error.whitelabel.enabled=false` to switch the default error page off.
26-
Doing so restores the default of the servlet container that you are using.
27-
Note that Spring Boot still tries to resolve the error view, so you should probably add your own error page rather than disabling it completely.
28-
29-
Overriding the error page with your own depends on the templating technology that you use.
30-
For example, if you use Thymeleaf, you can add an `error.html` template.
31-
If you use FreeMarker, you can add an `error.ftlh` template.
32-
In general, you need a `View` that resolves with a name of `error` or a `@Controller` that handles the `/error` path.
33-
Unless you replaced some of the default configuration, you should find a `BeanNameViewResolver` in your `ApplicationContext`, so a `@Bean` named `error` would be one way of doing that.
34-
See {code-spring-boot-autoconfigure-src}/web/servlet/error/ErrorMvcAutoConfiguration.java[`ErrorMvcAutoConfiguration`] for more options.
35-
36-
See also the section on xref:reference:web/servlet.adoc#web.servlet.spring-mvc.error-handling[] for details of how to register handlers in the servlet container.
37-
38-
39-
4020
[[howto.actuator.customizing-sanitization]]
4121
== Customizing Sanitization
4222

spring-boot-project/spring-boot-docs/src/docs/antora/modules/how-to/pages/spring-mvc.adoc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,23 @@ For more detail, see the following sections:
240240
* {code-spring-boot-autoconfigure-src}/thymeleaf/ThymeleafAutoConfiguration.java[`ThymeleafAutoConfiguration`]
241241
* {code-spring-boot-autoconfigure-src}/freemarker/FreeMarkerAutoConfiguration.java[`FreeMarkerAutoConfiguration`]
242242
* {code-spring-boot-autoconfigure-src}/groovy/template/GroovyTemplateAutoConfiguration.java[`GroovyTemplateAutoConfiguration`]
243+
244+
245+
246+
[[howto.spring-mvc.customize-whitelabel-error-page]]
247+
== Customize the '`whitelabel`' Error Page
248+
249+
Spring Boot installs a '`whitelabel`' error page that you see in a browser client if you encounter a server error (machine clients consuming JSON and other media types should see a sensible response with the right error code).
250+
251+
NOTE: Set `server.error.whitelabel.enabled=false` to switch the default error page off.
252+
Doing so restores the default of the servlet container that you are using.
253+
Note that Spring Boot still tries to resolve the error view, so you should probably add your own error page rather than disabling it completely.
254+
255+
Overriding the error page with your own depends on the templating technology that you use.
256+
For example, if you use Thymeleaf, you can add an `error.html` template.
257+
If you use FreeMarker, you can add an `error.ftlh` template.
258+
In general, you need a `View` that resolves with a name of `error` or a `@Controller` that handles the `/error` path.
259+
Unless you replaced some of the default configuration, you should find a `BeanNameViewResolver` in your `ApplicationContext`, so a `@Bean` named `error` would be one way of doing that.
260+
See {code-spring-boot-autoconfigure-src}/web/servlet/error/ErrorMvcAutoConfiguration.java[`ErrorMvcAutoConfiguration`] for more options.
261+
262+
See also the section on xref:reference:web/servlet.adoc#web.servlet.spring-mvc.error-handling[] for details of how to register handlers in the servlet container.

0 commit comments

Comments
 (0)