use ** in the fisrt and middle of the path in http.authorizeExchange() .pathMatchers(
- User
use ** in the fisrt and middle of the path in http.authorizeExchange() .pathMatchers(
- Assistant
"/admin/").hasRole("ADMIN") .pathMatchers("/user/").authenticated() .pathMatchers("/").permitAll() .anyExchange().denyAll() .and().csrf().disable() .build();
- User
use ** in the fisrt and middle of the path in http.authorizeExchange() .pathMatchers()
- Assistant
Sure, here's an example of using ** in the first and middle of the path in http.authorizeExchange().
http .authorizeExchange() .pathMatchers("/public/**").permitAll() .pathMatchers("/users/**/profiles/**").hasAnyAuthority("USER", "ADMIN") .pathMatchers("/users/**").hasAuthority("ADMIN") .pathMatchers("/**").denyAll() .and() .csrf().disable();In this example, the ** symbol is used in the middle of the second path matcher to match any number of sub-paths between the
/users/and/profiles/segments. The ** symbol is not used at the end of any of the path matchers. - User
Invalid mapping pattern detected: /test/**/tst ^ No more pattern data allowed after {*...} or ** pattern element
Action:
Fix this pattern in your application or switch to the legacy parser implementation with 'spring.mvc.pathmatch.matching-strategy=ant_path_matcher'.
- Assistant
This error message indicates that the endpoint mapping pattern "/test/**/tst" is not valid. The error message specifically mentions that no more pattern data is allowed after
{*...}or**pattern element.To fix this issue, you can use one of the following options:
- Remove the
**from the middle of the pattern. For example, you could change "/test/**/tst" to "/test/*/tst" to only match one level of sub-paths instead of any number of sub-paths. - Use the legacy parser implementation by setting
spring.mvc.pathmatch.matching-strategy=ant_path_matcherin your application properties or configuration file. This will allow you to use the**pattern element in the middle of the pattern.
Here is an example of using the legacy parser implementation with the
**pattern element:@Configuration public class MyConfig implements WebMvcConfigurer { @Override public void configurePathMatch(PathMatchConfigurer configurer) { AntPathMatcher pathMatcher = new AntPathMatcher(); pathMatcher.setCachePatterns(false); // disable pattern caching for dynamic resolution configurer.setPathMatcher(pathMatcher); // configure Spring MVC to use the AntPathMatcher } @Bean public HandlerMappingIntrospector handlerMappingIntrospector() { return new HandlerMappingIntrospector(); } } - Remove the
- User
Invalid mapping pattern detected: /test/**/tst ^ No more pattern data allowed after {*…} or ** pattern element
Action:
Fix this pattern in your application or switch to the legacy parser implementation with ‘spring.mvc.pathmatch.matching-strategy=ant_path_matcher’.
- Assistant
This error message indicates that the endpoint mapping pattern "/test/**/tst" is not valid because there is no more pattern data allowed after
{*...}or**pattern element.To fix this issue, you can either fix the pattern or switch to the legacy parser implementation. Here are the two options:
- Fixing the pattern:
You can modify the pattern to follow the pattern rules. If you don't need the
**pattern in your code at all, remove it as follows:
/test/*/tstThis will match only one level of sub-paths. If you do require more flexibility, you can put the
**pattern at the end of the pattern as shown below:/test/**/tstThis will match any number of sub-paths after
/test/before thetstsegment.- Switching to the legacy parser implementation:
If you want to keep the original pattern unchanged, you can switch to the legacy parser implementation. This can be done by setting the following configuration in the
application.propertiesfile:
- Fixing the pattern:
You can modify the pattern to follow the pattern rules. If you don't need the