天天看點

springboot請求url中含有“.”的問題和處理方法

接口請求為

@RequestMapping(value = "/test/{id}/{payCount}", method = RequestMethod.GET)
           

當payCount為包含小數點“.”時會被丢失内容如payCount=0.01,debug中會顯示為0,

原因:springmvc在請求路徑最後包含"."的時候會被會略掉,如通路www.1234.com/test/index.do

時則會被解析為www.1234.com/test/index

需要改為下邊的寫法

@RequestMapping(value = "/test/{id}/{payCount:.+}", method = RequestMethod.GET)