雷火电竞-中国电竞赛事及体育赛事平台

歡迎來到入門教程網(wǎng)!

Java

當前位置:主頁 > 軟件編程 > Java >

如何使用Spring工具類動態(tài)匹配url

來源:本站原創(chuàng)|時間:2020-01-10|欄目:Java|點擊:

這篇文章主要介紹了如何使用Spring工具類動態(tài)匹配url,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下

該方法主要是借助spring對于路徑的通配符匹配的實現(xiàn),來實現(xiàn)自己公司業(yè)務需求。

package com.stylefeng.guns.gateway.modular;

import org.apache.commons.lang3.StringUtils;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.PathMatcher;

/**
 * @author ztkj-hzb
 * @Date 2019/8/28 17:10
 * @Description
 */
public class UrlMatch {

  private UrlMatch() {
  }

  /**
   * 匹配資料
   *
   * @param patternPath 模糊匹配表達式
   * @param requestPath 待匹配的url
   * @return
   */
  public static boolean match(String patternPath, String requestPath) {
    if (StringUtils.isEmpty(patternPath) || StringUtils.isEmpty(requestPath)) {
      return false;
    }
    PathMatcher matcher = new AntPathMatcher();
    return matcher.match(patternPath, requestPath);
  }

}

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持我們。

上一篇:springboot多文件上傳代碼實例及解析

欄    目:Java

下一篇:Spring實戰(zhàn)之使用@Resource配置依賴操作示例

本文標題:如何使用Spring工具類動態(tài)匹配url

本文地址:http://www.jygsgssxh.com/a1/Java/8862.html

網(wǎng)頁制作CMS教程網(wǎng)絡編程軟件編程腳本語言數(shù)據(jù)庫服務器

如果侵犯了您的權利,請與我們聯(lián)系,我們將在24小時內(nèi)進行處理、任何非本站因素導致的法律后果,本站均不負任何責任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權所有