Package org.springframework.security.web.util.matcher

# Class DispatcherTypeRequestMatcher

java.lang.Object
org.springframework.security.web.util.matcher.DispatcherTypeRequestMatcher

All Implemented Interfaces:
  `RequestMatcher`

public class DispatcherTypeRequestMatcher extends Object implements RequestMatcher
Checks the `DispatcherType` to decide whether to match a given request. `HttpServletRequest`. Can also be configured to match a specific HTTP method.

Since:
  5.5

## Nested Class Summary

## Nested classes/interfaces inherited from interface org.springframework.security.web.util.matcher.RequestMatcher

`RequestMatcher.MatchResult`

## Constructor Summary

Constructors
Constructor
Description
`DispatcherTypeRequestMatcher(jakarta.servlet.DispatcherType dispatcherType)`
Creates an instance which matches requests with the provided `DispatcherType`
`DispatcherTypeRequestMatcher(jakarta.servlet.DispatcherType dispatcherType, org.springframework.http.HttpMethod httpMethod)`
Creates an instance which matches requests with the provided `DispatcherType` and `HttpMethod`

## Method Summary

Modifier and Type
Method
Description
`boolean`
`matches(jakarta.servlet.http.HttpServletRequest request)`
Performs the match against the request's method and dispatcher type.
`String`
`toString()`

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

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

### Methods inherited from interface org.springframework.security.web.util.matcher.RequestMatcher

`matcher`

## Constructor Details

### DispatcherTypeRequestMatcher

public DispatcherTypeRequestMatcher(jakarta.servlet.DispatcherType dispatcherType)
Creates an instance which matches requests with the provided `DispatcherType`

Parameters:
  `dispatcherType` - the type to match against

### DispatcherTypeRequestMatcher

public DispatcherTypeRequestMatcher(jakarta.servlet.DispatcherType dispatcherType, @Nullable org.springframework.http.HttpMethod httpMethod)
Creates an instance which matches requests with the provided `DispatcherType` and `HttpMethod`

Parameters:
  `dispatcherType` - the type to match against
  `httpMethod` - the HTTP method to match. May be null to match all methods.

## Method Details

### matches

public boolean matches(jakarta.servlet.http.HttpServletRequest request)
Performs the match against the request's method and dispatcher type.

Specified by:
  `matches` in interface `RequestMatcher`
Parameters:
  `request` - the request to check for a match
Returns:
  true if the http method and dispatcher type align

### toString

public String toString()

Overrides:
  `toString` in class `Object`