springMvc web项目中restful风格的api路径中有小数点会被过滤后台拿不到最后一个小数点的问题

时间:2023-03-09 08:48:59
springMvc web项目中restful风格的api路径中有小数点会被过滤后台拿不到最后一个小数点的问题

有两种解决方案:

1:在api路径中加入:.+

 @RequestMapping("/findByIp/{ip:.+}")
public Object test(@PathVariable String ip) {
System.out.println(ip);
return "";
 }

但这种方式在web服务中感觉太过于鸡肋

所以在springMvc.xml中配置mvc标签

2.<mvc:path-matching registered-suffixes-only="true"/>

 <mvc:annotation-driven >
<mvc:path-matching registered-suffixes-only="true"/>
</mvc:annotation-driven>

原文链接:

https://blog.****.net/weixin_42599091/article/details/82666646

声明:此博客为个人学习之用,如与其他作品雷同,纯属巧合,转载请指明出处!