Skip to content

Commit e735c2d

Browse files
committed
Improve Filter overview in reference docs
Closes spring-projectsgh-30454
1 parent 3cb498f commit e735c2d

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

framework-docs/modules/ROOT/pages/web/webmvc/filters.adoc

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,30 @@
33

44
[.small]#xref:web/webflux/reactive-spring.adoc#webflux-filters[See equivalent in the Reactive stack]#
55

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:
710

811
* xref:web/webmvc/filters.adoc#filters-http-put[Form Data]
912
* xref:web/webmvc/filters.adoc#filters-forwarded-headers[Forwarded Headers]
1013
* xref:web/webmvc/filters.adoc#filters-shallow-etag[Shallow ETag]
1114
* xref:web/webmvc/filters.adoc#filters-cors[CORS]
1215
* xref:web/webmvc/filters.adoc#filters.url-handler[URL Handler]
1316

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.
1730

1831

1932
[[filters-http-put]]

0 commit comments

Comments
 (0)