如何使用Spring工具類動態(tài)匹配url
這篇文章主要介紹了如何使用Spring工具類動態(tài)匹配url,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
該方法主要是借助spring對于路徑的通配符匹配的實(shí)現(xiàn),來實(shí)現(xiàn)自己公司業(yè)務(wù)需求。
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 模糊匹配表達(dá)式 * @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)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
詳解如何獨(dú)立使用ribbon實(shí)現(xiàn)業(yè)務(wù)客戶端負(fù)載均衡
這篇文章主要為大家介紹了詳解如何獨(dú)立使用ribbon實(shí)現(xiàn)業(yè)務(wù)客戶端負(fù)載均衡,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-06-06Java基礎(chǔ)之邏輯運(yùn)算符知識總結(jié)
今天帶大家學(xué)習(xí)Java基礎(chǔ)知識,文中對Java邏輯運(yùn)算符進(jìn)行了非常詳細(xì)的介紹,有相關(guān)代碼示例,對正在學(xué)習(xí)java的小伙伴很有幫助,需要的朋友可以參考下2021-05-05javaweb servlet中使用請求轉(zhuǎn)發(fā)亂碼的實(shí)現(xiàn)
下面小編就為大家?guī)硪黄猨avaweb servlet中使用請求轉(zhuǎn)發(fā)亂碼的實(shí)現(xiàn)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-08-08