Update Documentation for PathPatternRequestMatcher

Issue gh-16765
This commit is contained in:
Josh Cummings 2025-04-22 14:44:01 -06:00
parent 0ab01eac14
commit 61d6fbc2a9
No known key found for this signature in database
GPG Key ID: 869B37A20E876129
2 changed files with 4 additions and 4 deletions

View File

@ -401,7 +401,7 @@ Instead of taking this responsibility away from developers, now it is simpler to
[method,java]
----
PathPatternRequestParser.Builder servlet = PathPatternRequestParser.servletPath("/mvc");
PathPatternRequestParser.Builder servlet = PathPatternRequestParser.withDefaults().basePath("/mvc");
http
.authorizeHttpRequests((authorize) -> authorize
.requestMatchers(servlet.pattern("/orders/**").matcher()).authenticated()
@ -409,11 +409,11 @@ http
----
For paths that belong to the default servlet, use `PathPatternRequestParser.path()` instead:
For paths that belong to the default servlet, use `PathPatternRequestParser.withDefaults()` instead:
[method,java]
----
PathPatternRequestParser.Builder request = PathPatternRequestParser.path();
PathPatternRequestParser.Builder request = PathPatternRequestParser.withDefaults();
http
.authorizeHttpRequests((authorize) -> authorize
.requestMatchers(request.pattern("/js/**").matcher()).authenticated()

View File

@ -594,7 +594,7 @@ import static org.springframework.security.web.servlet.util.matcher.PathPatternR
@Bean
SecurityFilterChain appEndpoints(HttpSecurity http) {
PathPatternRequestMatcher.Builder mvc = withDefaults().servletPath("/spring-mvc");
PathPatternRequestMatcher.Builder mvc = withDefaults().basePath("/spring-mvc");
http
.authorizeHttpRequests((authorize) -> authorize
.requestMatchers(mvc.matcher("/admin/**")).hasAuthority("admin")