|
3 | 3 |
|
4 | 4 | [.small]#xref:web/webflux/reactive-spring.adoc#webflux-filters[See equivalent in the Reactive stack]# |
5 | 5 |
|
6 | | -The `spring-web` module provides some useful filters: |
| 6 | +In the Servlet API, you can add a `jakarta.servlet.Filter` to apply interception-style logic |
| 7 | +before and after the rest of the processing chain of filters and the target `Servlet`. |
| 8 | + |
| 9 | +The `spring-web` module has a number of built-in `Filter` implementations: |
7 | 10 |
|
8 | 11 | * xref:web/webmvc/filters.adoc#filters-http-put[Form Data] |
9 | 12 | * xref:web/webmvc/filters.adoc#filters-forwarded-headers[Forwarded Headers] |
10 | 13 | * xref:web/webmvc/filters.adoc#filters-shallow-etag[Shallow ETag] |
11 | 14 | * xref:web/webmvc/filters.adoc#filters-cors[CORS] |
12 | 15 | * xref:web/webmvc/filters.adoc#filters.url-handler[URL Handler] |
13 | 16 |
|
14 | | -Servlet filters can be configured in the `web.xml` configuration file or using Servlet annotations. |
15 | | -If you are using Spring Boot, you can |
16 | | -{spring-boot-docs}/how-to/webserver.html#howto.webserver.add-servlet-filter-listener.spring-bean[declare them as beans and configure them as part of your application]. |
| 17 | +There are also base class implementations for use in Spring applications: |
| 18 | + |
| 19 | +* `GenericFilterBean` -- base class for a `Filter` configured as a Spring bean; |
| 20 | +integrates with the Spring `ApplicationContext` lifecycle. |
| 21 | +* `OncePerRequestFilter` -- extension of `GenericFilterBean` that supports a single |
| 22 | +invocation at the start of a request, i.e. during the `REQUEST` dispatch phase, and |
| 23 | +ignoring further handling via `FORWARD` dispatches. The filter also provides control |
| 24 | +over whether the `Filter` gets involved in `ASYNC` and `ERROR` dispatches. |
| 25 | + |
| 26 | +Servlet filters can be configured in `web.xml` or via Servlet annotations. |
| 27 | +In a Spring Boot application , you can |
| 28 | +{spring-boot-docs}/how-to/webserver.html#howto.webserver.add-servlet-filter-listener.spring-bean[declare Filter's as beans] |
| 29 | +and Boot will have them configured. |
17 | 30 |
|
18 | 31 |
|
19 | 32 | [[filters-http-put]] |
|
0 commit comments