溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

使用Spring工具類動態(tài)匹配url的方法

發(fā)布時間:2021-02-02 10:10:35 來源:億速云 閱讀:374 作者:小新 欄目:編程語言

這篇文章主要介紹了使用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);
  }

}

感謝你能夠認真閱讀完這篇文章,希望小編分享的“使用Spring工具類動態(tài)匹配url的方法”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關(guān)注億速云行業(yè)資訊頻道,更多相關(guān)知識等著你來學習!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI