当前位置:网站首页>AntPathMatcher使用
AntPathMatcher使用
2022-08-02 01:36:00 【明快de玄米61】
ant匹配规则
规则:
字符wildcard 描述
? 匹配一个字符
* 匹配0个或者多个字符
** 匹配0个或者多个目录
官方示例:
1、com/t?st.jsp
匹配: com/test.jsp , com/tast.jsp , com/txst.jsp
2、com/*.jsp 匹配: com文件夹下的全部.jsp文件 3、com/**/test.jsp
匹配: com文件夹和子文件夹下的全部.jsp文件,
4、org/springframework/**/*.jsp
匹配: org/springframework文件夹和子文件夹下的全部.jsp文件
5、org/**/servlet/bla.jsp
匹配: org/springframework/servlet/bla.jsp,
org/springframework/testing/servlet/bla.jsp,
org/servlet/bla.jsp
PathMatcher接口方法讲解(AntPathMatcher实现PathMatcher接口)
说明:主要是判断是否匹配pattern,并解析出path中的参数
package org.springframework.util;
public interface PathMatcher {
/** * 判断传入的path是否可以作为pattern使用 */
boolean isPattern(String path);
/** * 使用pattern匹配path */
boolean match(String pattern, String path);
/** * 如名,是否开始部分匹配 */
boolean matchStart(String pattern, String path);
/** * 提取path中匹配到的部分,如pattern(myroot/*.html),path(myroot/myfile.html),返回myfile.html */
String extractPathWithinPattern(String pattern, String path);
/** * 提取path中匹配到的部分,只是这边还需跟占位符配对为map, * 如pattern(/hotels/{hotel}),path(/hotels/1),解析出"hotel"->"1" */
Map<String, String> extractUriTemplateVariables(String pattern, String path);
/** * 提供比较器 */
Comparator<String> getPatternComparator(String path);
/** * 合并pattern,pattern1然后pattern2 */
String combine(String pattern1, String pattern2);
}
边栏推荐
猜你喜欢
NFT到底有哪些实际用途?
Pcie the inbound and outbound
Flex布局详解
Can‘t connect to MySQL server on ‘localhost3306‘ (10061) 简洁明了的解决方法
第一次写对牛客的编程面试题:输入一个字符串,返回该字符串出现最多的字母
typescript30 - any type
力扣 1161. 最大层内元素和
Record the pits where an error occurs when an array is converted to a collection, and try to use an array of packaging types for conversion
Flink_CDC construction and simple use
YGG 公会发展计划第 1 季总结
随机推荐
typescript38-class的构造函数实例方法继承(implement)
ECMAScript 2022 正式发布,有你了解过的吗?
创新项目实战之智能跟随机器人原理与代码实现
C语言实验六 一维数组程序设计
5年自动化测试经验的一些感悟:做UI自动化一定要跨过这10个坑
6-24漏洞利用-vnc密码破解
力扣 1161. 最大层内元素和
datax与datax-web安装部署
typescript36-class的构造函数实例方法
typescript32-ts中的typeof
飞桨助力航天宏图PIE-Engine地球科学引擎构建
The characteristics and principle of typescript29 - enumeration type
go泛型使用方法
Reflex WMS中阶系列6:对一个装货重复run pick会有什么后果?
Test Cases: Four-Step Test Design Approach
Kubernetes — 核心资源对象 — Controller
Constructor instance method of typescript36-class
百度、百图生科 | HelixFold-Single: 使用蛋白质语言模型作为替代进行无MSA蛋白质结构预测
Understand the big model in seconds | 3 steps to get AI to write a summary
第一次写对牛客的编程面试题:输入一个字符串,返回该字符串出现最多的字母