如何使用Spring工具类动态匹配url
时间:2021-07-09 08:27:58|栏目:JAVA代码|点击: 次
这篇文章主要介绍了如何使用Spring工具类动态匹配url,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
该方法主要是借助spring对于路径的通配符匹配的实现,来实现自己公司业务需求。
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);
}
}
栏 目:JAVA代码
下一篇:SpringMVC 方法四种类型返回值总结(你用过几种)
本文标题:如何使用Spring工具类动态匹配url
本文地址:http://www.codeinn.net/misctech/154904.html


阅读排行
- 1Java Swing组件BoxLayout布局用法示例
- 2java中-jar 与nohup的对比
- 3Java邮件发送程序(可以同时发给多个地址、可以带附件)
- 4Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.Type异常
- 5Java中自定义异常详解及实例代码
- 6深入理解Java中的克隆
- 7java读取excel文件的两种方法
- 8解析SpringSecurity+JWT认证流程实现
- 9spring boot里增加表单验证hibernate-validator并在freemarker模板里显示错误信息(推荐)
- 10深入解析java虚拟机




