当前位置:网站首页>AntPathMatcher uses
AntPathMatcher uses
2022-08-02 01:55:00 【Bright de Xuan rice 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);
}
边栏推荐
猜你喜欢
随机推荐
When paying attention to the "Internet +" model, you usually only focus on the "Internet +" model itself
检查IP或端口是否被封
《自然语言处理实战入门》 基于知识图谱的问答机器人
外包干了三年,废了...
编码经验之谈
Oracle data to mysql FlinkSQL CDC to achieve synchronization
For effective automated testing, these software testing tools must be collected!!!
Detailed explanation of fastjson
雇用WordPress开发人员:4个实用的方法
哈希表
密码学的基础:X.690和对应的BER CER DER编码
创新项目实战之智能跟随机器人原理与代码实现
【ORB_SLAM2】SetPose、UpdatePoseMatrices
¶Backtop 回到顶部 不生效
哈希冲突和一致性哈希
C语言之插入字符简单练习
Multi-Party Threshold Private Set Intersection with Sublinear Communication-2021: Interpretation
Newton's theorem and related corollaries
About MySQL data insertion (advanced usage)
LeetCode刷题日记:34、 在排序数组中查找元素的第一个和最后一个位置









