zoukankan      html  css  js  c++  java
  • Spring源码解析

    文章摘要:

      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

  • 相关阅读:
    asp.net操作cookie
    前端实现浏览器端大文件分片上传
    百度WebUploader实现浏览器端大文件分片上传
    网页实现浏览器端大文件分片上传
    c#.net实现浏览器端大文件分片上传
    SpringCloud实现浏览器端大文件分片上传
    jsp实现浏览器端大文件分片上传
    Java实现浏览器端大文件分片上传解决方案
    Java实现浏览器端大文件分片上传功能
    Java实现浏览器端大文件分片上传方案
  • 原文地址:https://www.cnblogs.com/jifeng/p/5915572.html
Copyright © 2011-2022 走看看