当前位置:网站首页>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);
}
边栏推荐
猜你喜欢
随机推荐
typescript31-any类型
设备树学习
Pcie the inbound and outbound
hash table
Use flex-wrap to wrap lines in flex layout
Maxwell 一款简单易上手的实时抓取Mysql数据的软件
dbeaver连接MySQL数据库及错误Connection refusedconnect处理
【轮式里程计】
软件测试功能测试全套常见面试题【开放性思维题】面试总结4-3
typescript29-枚举类型的特点和原理
滴滴秋招提前批正式开始,现在投递免笔试
使用百度EasyDL实现厂区工人抽烟行为识别
信息收集之cms指纹识别
typescript32-ts中的typeof
27英寸横置大屏+实体按键,全新探险者才是安全而合理的做法!
内部类、异常简单介绍(第十天)
C语言实验七 二维数组程序设计
Flink_CDC construction and simple use
华为5年女测试工程师离职:多么痛的领悟...
Day.js 常用方法