spring boot 配置自己的 path 匹配规则

来源:互联网 发布:java二维数组输出矩阵 编辑:程序博客网 时间:2024/05/29 18:46

spring boot 配置自己的 path 匹配规则

how do

import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;/** * @作者 Mitkey * @时间 2017年1月19日 下午3:31:26 * @类说明: * @版本 xx */@SpringBootApplicationpublic class Application extends WebMvcConfigurationSupport {    public static void main(String[] args) {        SpringApplication.run(Application.class, args);    }    @Override    protected void configurePathMatch(PathMatchConfigurer configurer) {        super.configurePathMatch(configurer);        // 常用的两种        // 匹配结尾 / :会识别 url 的最后一个字符是否为 /        // localhost:8080/test 与 localhost:8080/test/ 等价        configurer.setUseTrailingSlashMatch(true);        // 匹配后缀名:会识别 xx.* 后缀的内容        // localhost:8080/test 与 localhost:8080/test.jsp 等价        configurer.setUseSuffixPatternMatch(true);        // TODO PathMatchConfigurer 还提供其他的一些 api 以供使用    }}
0 0