您的位置:首页 > 编程语言 > Java开发

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

2017-01-19 15:58 891 查看
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
*/
@SpringBootApplication
public 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 以供使用
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  spring path 匹配 定制