From a63d0b4e161767f1e17c46683a525be5dd3e1064 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Mon, 22 Sep 2014 12:14:58 +0100 Subject: [PATCH] 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 --- spring-boot-docs/src/main/asciidoc/howto.adoc | 4 +++- .../main/asciidoc/spring-boot-features.adoc | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-docs/src/main/asciidoc/howto.adoc index 71aac600dc3..2f6704adedf 100644 --- a/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -1320,7 +1320,7 @@ in the ``Production-ready features'' section. [[howto-customize-the-whitelabel-error-page]] === Customize the ``whitelabel'' error page -The Actuator installs a ``whitelabel'' error page that you will see in browser client if +Spring Boot installs a ``whitelabel'' error page that you will see in 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). To switch it off you can set `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 `ApplicationContext` so a `@Bean` with id `error` would be a simple way of doing that. Look at {sc-spring-boot-autoconfigure}/web/ErrorMvcAutoConfiguration.{sc-ext}[`ErrorMvcAutoConfiguration`] for more options. +See also the section on <> for details of +how to register handlers in the servlet container. [[howto-security]] diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 0d9f5e2065f..227e85684e5 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -998,6 +998,24 @@ You can also use regular Spring MVC features like http://docs.spring.io/spring/d methods] and http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#mvc-ann-controller-advice[`@ControllerAdvice`]. The `ErrorController` will then pick up any unhandled exceptions. +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, +like Jersey and Wicket), then the `Filter` has to be explicitly registered as an `ERROR` dispatcher, e.g. + +[source,java,indent=0,subs="verbatim,quotes,attributes"] +---- +@Bean +public FilterRegistrationBean myFilter() { + + FilterRegistrationBean registration = new FilterRegistrationBean(); + registration.setFilter(new MyFilter()); + ... + registration.setDispatcherTypes(EnumSet.allOf(DispatcherType.class)); + return registration; + +} +---- + +(the default `FilterRegistrationBean` does not include the `ERROR` dispatcher type). [[boot-features-embedded-container]]