2010-11-01 40 views

回答

17

@RequestParam將請求參數綁定到方法中的參數。在您的示例中,GET請求中名爲「portfolioIdRequest」的參數的值將被傳遞作爲您的方法的「portfolioIdRequest」參數。一個更具體的例子 - 如果請求的URL是

http://hostname/portfolio/123?portfolioIdRequest=456 

那麼參數「portfolioIdRequest」的值將是「456」。

更多資訊http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-ann-requestparam

@PathVariable類似地結合URI模板變量 「portfolioIdPath」 的方法參數 「portfolioIdPath」 的值。例如,如果您的URI是

/portfolio/123 

那麼「portfolioIdPath」方法參數的值將是「123」。

這裏更多的信息http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-ann-requestmapping-uri-templates

2

@RequestParam標識由所述客戶端(用戶)發送的HTTP GET或POST參數,而提取@RequestMapping URL的一個段從請求變化到請求:

http://host/?var=1 

在上面的URL 「var」是一個requestparam。

http://host/registration/{which} 

和上述URL的{其中}是一個請求映射。你可以打電話給你的服務,如:

http://host/registration/user 

或類似

http://host/registration/firm 

在你的應用程序,你可以訪問的值{這}(其中=「用戶」,並在第二第一種情況下,其=「firm」

0

這取決於你想處理您的請求的方式

@RequestParam example 
(request)http://something.com/owner?ownerId=1234 

@PathVariable example 
(request) http://something.com/owner/1234 
(in tour code) /owner/{ownerId} 
相關問題