zoukankan      html  css  js  c++  java
  • 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.  
      }
  • 相关阅读:
    Eureka 服务的注册和发现
    springcloud 中文文档
    mysql 7 种 join
    通用 mapper
    docker 容器操作( 以 tomcat 为例 )
    linux下安装phpunit简单方法
    图片优化的几个小工具
    安装基准测试工具sysbench
    安装pcntl以实现php多进程
    安装memcache及php的memcached模块
  • 原文地址:https://www.cnblogs.com/javalinux/p/14809664.html
Copyright © 2011-2022 走看看