gpt4 book ai didi

spring - antMatcher和mvcMatcher之间的区别

转载 作者:行者123 更新时间:2023-12-03 07:35:15 26 4
gpt4 key购买 nike

HttpSecurityantMatcher()mvcMatcher()函数有什么区别?

谁能解释何时使用它们?

最佳答案

正如official documentation中明确指出的那样,该方法的签名还包括-

antMatcher(String antPattern) - Allows configuring the HttpSecurity to only be invoked when matching the provided ant pattern.

mvcMatcher(String mvcPattern) - Allows configuring the HttpSecurity to only be invoked when matching the provided Spring MVC pattern.


通常, mvcMatcherantMatcher更安全。举个例子:
  • antMatchers("/secured") 仅与确切的/secured URL
  • 匹配
  • mvcMatchers("/secured") 匹配/secured以及/secured//secured.html/secured.xyz

  • 因此更加通用,还可以处理一些可能的配置错误。 mvcMatcher使用与Spring MVC用于匹配的规则相同(使用 @RequestMapping注释时)。

    If the current request will not be processed by Spring MVC, a reasonable default using the pattern as a ant pattern will be used. Source


    可以添加的是 mvcMatchers API(自4.1.1起)比 antMatchers API(自3.1起)更新。

    关于spring - antMatcher和mvcMatcher之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50536292/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com