All Known Implementing Classes:
AntPathMatcher

public interface PathMatcher
Strategy interface for String-based path matching.

Used by {link org.springframework.core.io.support.PathMatchingResourcePatternResolver}, {link org.springframework.web.servlet.handler.AbstractUrlHandlerMapping}, and {link org.springframework.web.servlet.mvc.WebContentInterceptor}.

The default implementation is {link AntPathMatcher}, supporting the Ant-style pattern syntax.

Since:
1.2
Author:
Juergen Hoeller see AntPathMatcher
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Does the given path represent a pattern that can be matched by an implementation of this interface?
    boolean
    match(String pattern, String path)
    Match the given path against the given pattern, according to this PathMatcher's matching strategy.
    boolean
    matchStart(String pattern, String path)
    Match the given path against the corresponding part of the given pattern, according to this PathMatcher's matching strategy.
  • Method Details

    • isPattern

      boolean isPattern(String path)
      Does the given path represent a pattern that can be matched by an implementation of this interface?

      If the return value is false, then the {link #match} method does not have to be used because direct equality comparisons on the static path Strings will lead to the same result.

      Parameters:
      path - the path to check
      Returns:
      true if the given path represents a pattern
    • match

      boolean match(String pattern, String path)
      Match the given path against the given pattern, according to this PathMatcher's matching strategy.
      Parameters:
      pattern - the pattern to match against
      path - the path to test
      Returns:
      true if the supplied path matched, false if it didn't
    • matchStart

      boolean matchStart(String pattern, String path)
      Match the given path against the corresponding part of the given pattern, according to this PathMatcher's matching strategy.

      Determines whether the pattern at least matches as far as the given base path goes, assuming that a full path may then match as well.

      Parameters:
      pattern - the pattern to match against
      path - the path to test
      Returns:
      true if the supplied path matched, false if it didn't