在使用restful风格编写接口时,路径参数是很常见的,有时候路径参数中会有小数,例如
http://localhost/xxx/{xxx}/{yyyy}
http://localhost/test/pathVal1/xx1.11
这时候会发现第二个路径参数接收到的实际值为xx1,后面的.11被截断了。
这是由于springmvc的路径后缀匹配模式导致的。
解决办法,关闭路径后缀匹配。
@Configuration
public class WebAppConfigurer extends WebMvcConfigurationSupport {
@Override
protected void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUseSuffixPatternMatch(false);
super.configurePathMatch(configurer);
}
}