文章摘要:

  1. ant匹配规则

  2. PathMatcher接口

  3. 通过测试用例看AntPathMatcher的使用

ant匹配规则

AntPathMatcher如名使用的ant 的匹配规则,我们先看看吧.

  字符wildcard    描述

   ?         匹配一个字符

  *         匹配0个及以上字符

  **         匹配0个及以上目录directories

看几个官方的例子吧:

  com/t?st.jsp -             匹配: com/test.jsp  ,  com/tast.jsp  ,  com/txst.jsp
  com/*.jsp -             匹配: com文件夹下的全部.jsp文件
  com/**/test.jsp -          匹配: com文件夹和子文件夹下的全部.jsp文件,
  org/springframework/**/*.jsp -    匹配: org/springframework文件夹和子文件夹下的全部.jsp文件
  org/**/servlet/bla.jsp -       匹配: org/springframework/servlet/bla.jsp  ,  org/springframework/testing/servlet/bla.jsp  ,  org/servlet/bla.jsp

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); }

http://www.cnblogs.com/leftthen/p/5212221.html

Spring源码解析 - AntPathMatcher的更多相关文章

  1. Spring源码解析 - AbstractBeanFactory 实现接口与父类分析

    我们先来看类图吧: 除了BeanFactory这一支的接口,AbstractBeanFactory主要实现了AliasRegistry和SingletonBeanRegistry接口. 这边主要提供了 ...

  2. spring 源码解析

    1. [文件] spring源码.txt ~ 15B     下载(167) ? 1 springн┤┬вио╬Ш: 2. [文件] spring源码分析之AOP.txt ~ 15KB     下载( ...

  3. Spring源码解析——循环依赖的解决方案

    一.前言 承接<Spring源码解析--创建bean>.<Spring源码解析--创建bean的实例>,我们今天接着聊聊,循环依赖的解决方案,即创建bean的ObjectFac ...

  4. Spring源码解析-ioc容器的设计

    Spring源码解析-ioc容器的设计 1 IoC容器系列的设计:BeanFactory和ApplicatioContext 在Spring容器中,主要分为两个主要的容器系列,一个是实现BeanFac ...

  5. Spring源码解析系列汇总

    相信我,你会收藏这篇文章的 本篇文章是这段时间撸出来的Spring源码解析系列文章的汇总,总共包含以下专题.喜欢的同学可以收藏起来以备不时之需 SpringIOC源码解析(上) 本篇文章搭建了IOC源 ...

  6. Spring源码解析之PropertyPlaceholderHelper(占位符解析器)

    Spring源码解析之PropertyPlaceholderHelper(占位符解析器) https://blog.csdn.net/weixin_39471249/article/details/7 ...

  7. Spring源码解析之BeanFactoryPostProcessor(三)

    在上一章中笔者介绍了refresh()的<1>处是如何获取beanFactory对象,下面我们要来学习refresh()方法的<2>处是如何调用invokeBeanFactor ...

  8. Spring源码解析之ConfigurationClassPostProcessor(二)

    上一个章节,笔者向大家介绍了spring是如何来过滤配置类的,下面我们来看看在过滤出配置类后,spring是如何来解析配置类的.首先过滤出来的配置类会存放在configCandidates列表, 在代 ...

  9. Spring源码解析之八finishBeanFactoryInitialization方法即初始化单例bean

    Spring源码解析之八finishBeanFactoryInitialization方法即初始化单例bean 七千字长文深刻解读,Spirng中是如何初始化单例bean的,和面试中最常问的Sprin ...

随机推荐

  1. hard

    硬盘电路板将信号转化为电压高低,电压控制电脉冲被送到磁头,产生一个电磁.磁盘和磁头很紧密.读写都是不断扫描磁盘的过程.有操作系统负责控制文件的组织,可能在不同的块中.

  2. C#检测本地网络状态

    using System; using System.Runtime.InteropServices; public static class NetTool { [Flags] private en ...

  3. softwareTesting_work1

    1.12306手机APP软件测评 首先是软件界面,iPhone版本和android版本长得是一模一样,虽然是注重功能的软件,但是一样样的界面让人完全感受不到软件设计者的诚意啊. 还有就是软件图片和图标 ...

  4. Jquery和Javascript 实际项目中写法基础-ajax和json (3)

    一.什么是JSON数据? 一种轻量级的数据交换格式.实际中知道如何使用即可. 软件开发我认为就是一个会用,然后知其原理的过程. 例子如下: <!DOCTYPE html> <html ...

  5. JavaScript:substr vs substring vs slice

    参考文章: JavaScript取子串方法slice,substr,substring对比表

  6. 详解 IOS 7.1 程序启动原理

    程序都是从Main方法入口的 IOS 也不例外 int main(int argc,char * argv[]) { @autoreleasepool { return UIApplicationMa ...

  7. WIFI功率修改

    1. 修改文件: mediatek/custom/工程/cgen/cfgdefault/CFG_WIFI_Default.h 2. 修改内容: {0x26, 0x26            ----- ...

  8. 移动端头像上传AJax input file

    jQuery中的Ajax不能支持 input file 需要用ajaxupload.js但是先需要引入jQuery文件 <script src="__PUBLIC__/js/ajaxf ...

  9. ABAP屏幕设计

    转自 http://www.cnblogs.com/aBaoRong/archive/2012/06/05/2536591.html abap 屏幕控制 ******************** 屏幕 ...

  10. C#中web页面之间传递数组参数

    一直以来用到的都是在url地址中传递string类型,那么如果是数组类型的该怎么传递呢? ]; arryStr[] = "a"; arryStr[] = "b" ...