Package org.springframework.web.servlet.config.annotation

# Class InterceptorRegistration

java.lang.Object
org.springframework.web.servlet.config.annotation.InterceptorRegistration

public class InterceptorRegistration extends Object
Assists with the creation of a `MappedInterceptor`.

Since:
  3.1
Author:
  Rossen Stoyanchev, Keith Donald

## Constructor Summary

Constructors
Constructor
Description
`InterceptorRegistration(HandlerInterceptor interceptor)`
Create an `InterceptorRegistration` instance.

## Method Summary

Modifier and Type
Method
Description
`InterceptorRegistration`
`addPathPatterns(String... patterns)`
Add patterns for URLs the interceptor should be included in.
`InterceptorRegistration`
`addPathPatterns(List<String> patterns)`
List-based variant of `addPathPatterns(String...)`.
`InterceptorRegistration`
`excludePathPatterns(String... patterns)`
Add patterns for URLs the interceptor should be excluded from.
`InterceptorRegistration`
`excludePathPatterns(List<String> patterns)`
List-based variant of `excludePathPatterns(String...)`.
`protected Object`
`getInterceptor()`
Build the underlying interceptor.
`protected int`
`getOrder()`
Return the order position to be used.
`InterceptorRegistration`
`order(int order)`
Specify an order position to be used.
`InterceptorRegistration`
`pathMatcher(org.springframework.util.PathMatcher pathMatcher)`
Configure the PathMatcher to use to match URL paths with against include and exclude patterns.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### InterceptorRegistration

public InterceptorRegistration(HandlerInterceptor interceptor)
Create an `InterceptorRegistration` instance.

## Method Details

### addPathPatterns

public InterceptorRegistration addPathPatterns(String... patterns)
Add patterns for URLs the interceptor should be included in.

For pattern syntax see `PathPattern` when parsed patterns are `enabled` or `AntPathMatcher` otherwise. The syntax is largely the same with `PathPattern` more tailored for web usage and more efficient.

### addPathPatterns

public InterceptorRegistration addPathPatterns(List<String> patterns)
List-based variant of `addPathPatterns(String...)`.

Since:
  5.0.3

### excludePathPatterns

public InterceptorRegistration excludePathPatterns(String... patterns)
Add patterns for URLs the interceptor should be excluded from.

For pattern syntax see `PathPattern` when parsed patterns are `enabled` or `AntPathMatcher` otherwise. The syntax is largely the same with `PathPattern` more tailored for web usage and more efficient.

### excludePathPatterns

public InterceptorRegistration excludePathPatterns(List<String> patterns)
List-based variant of `excludePathPatterns(String...)`.

Since:
  5.0.3

### pathMatcher

public InterceptorRegistration pathMatcher(org.springframework.util.PathMatcher pathMatcher)
Configure the PathMatcher to use to match URL paths with against include and exclude patterns.

This is an advanced property that should be used only when a customized `AntPathMatcher` or a custom PathMatcher is required.

By default this is `AntPathMatcher`.

Note: Setting `PathMatcher` enforces use of String pattern matching even when a `parsed` `RequestPath` is available.

### order

public InterceptorRegistration order(int order)
Specify an order position to be used. Default is 0.

Since:
  4.3.23

### getOrder

protected int getOrder()
Return the order position to be used.

### getInterceptor

protected Object getInterceptor()
Build the underlying interceptor. If URL patterns are provided, the returned type is `MappedInterceptor`; otherwise `HandlerInterceptor`.