spring - antMatcher 和 mvcMatcher 的区别
问题描述
和函数有什么区别HttpSecurity
?antMatcher()
mvcMatcher()
谁能解释何时使用它们?
解决方案
正如官方文档中明确说明的那样,这种方法的签名也有说明-
antMatcher(String antPattern)
- 允许将 配置HttpSecurity
为仅在匹配提供的 ant 模式时调用。
mvcMatcher(String mvcPattern)
- 允许配置HttpSecurity
仅在匹配提供的 Spring MVC 模式时调用。
通常mvcMatcher
比antMatcher
. 举个例子:
antMatchers("/secured")
仅匹配确切的/secured
URLmvcMatchers("/secured")
匹配/secured
以及/secured/
,/secured.html
,/secured.xyz
因此更通用,也可以处理一些可能的配置错误。
mvcMatcher
使用 Spring MVC 用于匹配的相同规则(使用@RequestMapping
注解时)。
如果 Spring MVC 不会处理当前请求,则将使用使用该模式作为 ant 模式的合理默认值。资源
可以补充一点,mvcMatchers
API(自 4.1.1 起)比API(自 3.1 起)更新。antMatchers
推荐阅读
- r - Ifelse...在这里使用正确的功能吗?
- r - 取消合并 ggplot 图例
- amazon-web-services - Quicksight 没有显示没有数据的月份(null?)
- c# - Oxyplot 跟踪器在 Xamarin.Forms 中不起作用
- django - Django Heroku:python:无法打开文件'manage.py':[Errno 2]没有这样的文件或目录
- image-processing - 计算 FIJI/ImageJ 中不同颜色的点之间的距离
- c# - 如何在后台运行 c# 控制台应用程序 .exe?
- oracle - Oracle查询从多个表中获取计数并并排显示
- vue.js - 将表单数据从一个组件传递到另一个组件
- ios - 如何将我的 Swift IOS 应用程序与 Pinterest 集成?