一、矩阵变量请求格式
/users;id=1,uname=jack
二、SpringBoot开启矩阵请求
- 首先查看springboot源码关于矩阵部分的内容
- 在 WebMvcAutoConfiguration配置类中。
-
@Override public void configurePathMatch(PathMatchConfigurer configurer) { if (this.mvcProperties.getPathmatch() .getMatchingStrategy() == WebMvcProperties.MatchingStrategy.PATH_PATTERN_PARSER) { configurer.setPatternParser(pathPatternParser); } configurer.setUseSuffixPatternMatch(this.mvcProperties.getPathmatch().isUseSuffixPattern()); configurer.setUseRegisteredSuffixPatternMatch( this.mvcProperties.getPathmatch().isUseRegisteredSuffixPattern()); this.dispatcherServletPath.ifAvailable((dispatcherPath) -> { String servletUrlMapping = dispatcherPath.getServletUrlMapping(); if (servletUrlMapping.equals("/") && singleDispatcherServlet()) { UrlPathHelper urlPathHelper = new UrlPathHelper(); urlPathHelper.setAlwaysUseFullPath(true); configurer.setUrlPathHelper(urlPathHelper); } }); }
- 在此方法中的 UrlPathHelper,中对矩阵变量做了截取,代码如下:
- 往上查看变量removeSemicolonContent,默认定义为true
-
/** * Set if ";" (semicolon) content should be stripped from the request URI. * <p>Default is "true". */ public void setRemoveSemicolonContent(boolean removeSemicolonContent) { checkReadOnly(); this.removeSemicolonContent = removeSemicolonContent; }
- 开启矩阵变量
- 第一种方式。创建配置类,实现WebMvcConfigurer接口。重写 configurePathMatch() 方法
@Override public void configurePathMatch(PathMatchConfigurer configurer) { UrlPathHelper urlPathHelper = new UrlPathHelper(); // 将默认值改为false urlPathHelper.setRemoveSemicolonContent(false); configurer.setUrlPathHelper(urlPathHelper); }
- 第二种方式,在SpringBoot添加容器
-
@Bean public WebMvcConfigurer webMvcConfigurer(){ return new WebMvcConfigurer() { @Override public void configurePathMatch(PathMatchConfigurer configurer) { UrlPathHelper urlPathHelper = new UrlPathHelper(); urlPathHelper.setRemoveSemicolonContent(false); configurer.setUrlPathHelper(urlPathHelper); } }; }
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 使用C#创建一个MCP客户端
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 按钮权限的设计及实现