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
pull/2035/head
Dave Syer 10 years ago
parent 5c84e17d10
commit a63d0b4e16

@ -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 <<boot-features-error-handling, Error Handling>> for details of
how to register handlers in the servlet container.
[[howto-security]]

@ -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]]

Loading…
Cancel
Save