今天爱分享给大家带来Missing matrix variable ‘name‘ for method parameter of type String【解决办法】,希望能够帮助到大家。
问题:添加注解 @MatrixVariable 失败
报错信息:Resolved [org.springframework.web.bind.MissingMatrixVariableException: Missing matrix variable ‘name’ for method parameter of type String]
报错截图:

报错原因:SpringBoot 默认是无法使用矩阵变量绑定参数的。需要覆盖 WebMvcConfigurer 中的 configurePathMatch 方法。
解决方案:新增 WebMvcConfig 配置类,实现 WebMvcConfigurer 接口,重写 configurePathMatch 方法。
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
UrlPathHelper urlPathHelper=new UrlPathHelper();
urlPathHelper.setRemoveSemicolonContent(false);
configurer.setUrlPathHelper(urlPathHelper);
}
}
如果是基于XML的配置,需要加enable-matrix-variables=”true”配置
<mvc:annotation-driven enable-matrix-variables="true" />
原文链接:https://itblood.website/1920.html,转载请注明出处。

![幸福家里蹲的养成方法V2.1.1 官方中文版+语音DLCV1.5+步兵补丁+存档[PC+安卓/1.5G] [同居互动SLG/中文/动态]](/wp-content/uploads/replace/2025/10/17/7e61cd1b6a86a232eb45b7c7d7ce3d25.webp)