• Spring的AntPathMatcher(路径匹配)


    1. import org.springframework.util.AntPathMatcher;
    2.  
      import org.springframework.util.PathMatcher;
    3.  
       
    4.  
      import junit.framework.TestCase;
    5.  
       
    6.  
      public class AntPathMatcherTest extends TestCase{
    7.  
           
    8.  
          public void testMatch() {  
    9.  
               
    10.  
              PathMatcher matcher = new AntPathMatcher();  
    11.  
               
    12.  
              //完全路径匹配  
    13.  
              //String requestPath="/user/list.htm?username=aaa&id=2&no=1&page=20";
    14.  
              //String patternPath="/user/list.htm**";
    15.  
          
    16.  
              //不完整路径匹配  
    17.  
              //String requestPath="/app/pub/login.do";
    18.  
              //String patternPath="/**/login.do";
    19.  
                
    20.  
              //模糊路径匹配  
    21.  
              //String requestPath="/app/pub/login.do";
    22.  
              //String patternPath="/**/*.do";
    23.  
                
    24.  
              //模糊单字符路径匹配  
    25.  
              String requestPath = "/app/pub/login.do";
    26.  
              String patternPath = "/**/lo?in.do";
    27.  
                
    28.  
              boolean result = matcher.match(patternPath, requestPath);  
    29.  
               
    30.  
              assertTrue(result);  
    31.  
          }  
    32.  
       
    33.  
      }
  • 相关阅读:
    sql注入常用的判断方法
    refere是什么
    mysql语句
    linux命令
    软件测试
    tcp和udp
    java面试干货
    为什么重写了equals方法一般也要重写hashCode方法
    redis源码解析
    Numpy复习
  • 原文地址:https://www.cnblogs.com/javalinux/p/14809664.html
Copyright © 2020-2023  润新知