Spring Boot 移行後のパス マッチング戦略: {*...} または ** パターン要素の後にはパターン データは許可されません
温馨提示:
本文最后更新于 2024年04月12日,已超过 48 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我。
I have migrated my springboot application from 2.7.4 to 3.2.3 following the official guide.
This is my controller:
@RestController
@RequestMapping("")
public class ProfileController {
@ResponseBody
@GetMapping(value = "/profile/{id}")
public Profileì getProfile(@PathVariable Long id){
//code
}
@ResponseBody
@PostMapping(value = "/profile")
public Profile insertProfile(@RequestBody Profile request) {
//code
}
This is my security config
@Configuration
@EnableWebSecurity
@EnableMethodSecurity(securedEnabled = true, jsr250Enabled = true)
public class SecurityAdapter {
@Bean
public WebSecurityCustomizer webSecurityCustomizer() {
return web -> web.ignoring()
.requestMatchers(HttpMethod.GET, "/**");
}
@Bean
protected SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
Filter authFilter = new CustomFilter();
http
.cors(AbstractHttpConfigurer::disable)
.csrf(AbstractHttpConfigurer::disable)
.exceptionHandling(e -> e.authenticationEntryPoint(accessDeniedHandler()))
.addFilterBefore(authFilter, BasicAuthenticationFilter.class)
.authorizeHttpRequests(a -> a.requestMatchers("**").authenticated());
return http.build();
}
So, when I call /profile/
in GET it works for web ignoring setting. when I call /profile/
in POST, it throws PatternParseException.
org.springframework.web.util.pattern.PatternParseException: No more pattern data allowed after {*...} or ** pattern element
If I put the property spring.mvc.pathmatch.matching-strategy
and force it to antPattern it works, but I would like understand why it not works without it. Please can you explain me why this occur? Thank you very much
正文到此结束
- 本文标签: 家庭宠物
- 本文链接: https://www.coder6.net/article/2443
- 版权声明: 本文由蚂蚁原创发布,转载请遵循《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权
热门推荐
-
浏览(193) 评论(0)