springMvc中restful風格的api路徑中把小數點當參數,SpringMvc中url有小數點

在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>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章