Skip to content

Commit a63d0b4

Browse files
author
Dave Syer
committed
Update docs with DispatcherType.ERROR for filters
Some frameworks handle all requests in a Filter, so you have to explicitly register it as an ERROR dispatcher. See gh-1272
1 parent 5c84e17 commit a63d0b4

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

spring-boot-docs/src/main/asciidoc/howto.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ in the ``Production-ready features'' section.
13201320

13211321
[[howto-customize-the-whitelabel-error-page]]
13221322
=== Customize the ``whitelabel'' error page
1323-
The Actuator installs a ``whitelabel'' error page that you will see in browser client if
1323+
Spring Boot installs a ``whitelabel'' error page that you will see in browser client if
13241324
you encounter a server error (machine clients consuming JSON and other media types should
13251325
see a sensible response with the right error code). To switch it off you can set
13261326
`error.whitelabel.enabled=false`, but normally in addition or alternatively to that you
@@ -1333,6 +1333,8 @@ of the default configuration you should find a `BeanNameViewResolver` in your
13331333
`ApplicationContext` so a `@Bean` with id `error` would be a simple way of doing that.
13341334
Look at {sc-spring-boot-autoconfigure}/web/ErrorMvcAutoConfiguration.{sc-ext}[`ErrorMvcAutoConfiguration`] for more options.
13351335

1336+
See also the section on <<boot-features-error-handling, Error Handling>> for details of
1337+
how to register handlers in the servlet container.
13361338

13371339

13381340
[[howto-security]]

spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,24 @@ You can also use regular Spring MVC features like http://docs.spring.io/spring/d
998998
methods] and http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#mvc-ann-controller-advice[`@ControllerAdvice`].
999999
The `ErrorController` will then pick up any unhandled exceptions.
10001000

1001+
N.B. if you register an `ErrorPage` with a path that will end up being handled by a `Filter` (e.g. as is common with some non-Spring web frameworks,
1002+
like Jersey and Wicket), then the `Filter` has to be explicitly registered as an `ERROR` dispatcher, e.g.
1003+
1004+
[source,java,indent=0,subs="verbatim,quotes,attributes"]
1005+
----
1006+
@Bean
1007+
public FilterRegistrationBean myFilter() {
1008+
1009+
FilterRegistrationBean registration = new FilterRegistrationBean();
1010+
registration.setFilter(new MyFilter());
1011+
...
1012+
registration.setDispatcherTypes(EnumSet.allOf(DispatcherType.class));
1013+
return registration;
1014+
1015+
}
1016+
----
1017+
1018+
(the default `FilterRegistrationBean` does not include the `ERROR` dispatcher type).
10011019

10021020

10031021
[[boot-features-embedded-container]]

0 commit comments

Comments
 (0)