springboot 请求路径有后缀_springboot指定访问url接口后缀:*.do或*.action

本文介绍了如何在SpringBoot中配置请求路径的后缀匹配,允许访问如/test.*的URL。通过`configurePathMatch`方法设置`useSuffixPatternMatch`和`useTrailingSlashMatch`为true,实现后缀模式匹配。同时提醒,若严格限制为特定后缀(如.do或.action),可能带来访问风险,并建议通常生产环境中不采用过于严格的限制。
摘要由CSDN通过智能技术生成

简介

springboot接口url匹配后缀,例如url访问/test,匹配后缀之后,访问/test.*同样可以;

项目实践

package com.springboot.sixmonth.common.filter;

import org.springframework.boot.web.servlet.ServletRegistrationBean;

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;

import org.springframework.web.servlet.DispatcherServlet;

import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;

import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**

* 过滤器

* @author hqc

* @Date 2019年3月20日

*

*/

@Configuration

public class WebMvcConfig extends WebMvcConfigurerAdapter {

/**

* -设置url后缀模式匹配规则

* -该设置匹配所有的后缀,使用.do或.action都可以

*/

@Override

p

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值