2010-11-01 64 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} 
相关问题