Class ServletFilterRegistration.Builder
- Enclosing class:
- ServletFilterRegistration
ServletFilterRegistration.-
Method Summary
Modifier and TypeMethodDescriptionasyncSupported(boolean value) Sets whether the filter supports asynchronous request processing.build()Validates and builds the registration.dispatcherTypes(jakarta.servlet.DispatcherType... value) Sets the dispatcher types the filter is mapped to.Sets the container filter name.order(int value) Sets the order: lower values run first (further out).urlPatterns(String... value) Sets the URL patterns the filter is mapped to.
-
Method Details
-
urlPatterns
Sets the URL patterns the filter is mapped to.Replaces any patterns set before. At least one is required. Duplicates are dropped, keeping the first. Each pattern must be one of:
- A path prefix:
/.../*(including"/*" ), where the trailing*is the only one. - An extension:
*.ext, with no/. - An exact path: starts with
/and contains no*. - The empty string
"" : the context root.
"/" (the default servlet, which a filter should not be mapped to), a blank (non-empty) pattern, and Jetty-only path-spec syntax such asregex:...or^.... Rejecting these keeps a typo such as"/console*" from silently mapping a boundary to nothing.- Parameters:
value- The URL patterns. Cannot benull .- Returns:
- This object.
- A path prefix:
-
dispatcherTypes
Sets the dispatcher types the filter is mapped to.Replaces the default of
DispatcherType.REQUEST, so listREQUEST explicitly when it is wanted. A filter mapped toASYNConly does not run for the plain request. AddFORWARD,ASYNCandERRORfor a boundary that must also see internal dispatches.- Parameters:
value- The dispatcher types. At least one is required, and none can benull .- Returns:
- This object.
-
order
Sets the order: lower values run first (further out).Defaults to
ServletFilterRegistration.DEFAULT_ORDER. SeeServletFilterRegistrationfor how it relates to authentication.- Parameters:
value- The order.- Returns:
- This object.
-
asyncSupported
Sets whether the filter supports asynchronous request processing.Defaults to
true . A filter in the chain that does not support it makesrequest.isAsyncSupported()false for every request it covers.- Parameters:
value- Whether async is supported.- Returns:
- This object.
-
name
Sets the container filter name.Optional; when absent the component generates a unique one. An explicit name must be unique among the registrations.
- Parameters:
value- The filter name. Can benull (generate one), but not blank.- Returns:
- This object.
-
build
Validates and builds the registration.- Returns:
- A new immutable registration.
- Throws:
IllegalArgumentException- If there is no URL pattern, a pattern is malformed, or there is no dispatcher type or anull one.
-