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

有两种解决方案:

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

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

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

 

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

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

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

 

相关文章:

  • 2022-12-23
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
  • 2021-07-08
  • 2021-11-20
  • 2022-01-17
猜你喜欢
  • 2021-08-05
  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
相关资源
相似解决方案