Suppose you want to write a url to get some order, you can say
www.mydomain.com/order/123
where 123 is orderId.
So now the URL that you will use in the spring mvc controller will look like
/order/{orderId}
Now the order identifier can be declared a path variable
@RequestMapping(value = " /order/{orderId}", method=RequestMethod.GET) public String getOrder(@PathVariable String orderId){
if you use the url www.mydomain.com/order/123 then the variable orderId will be populated with 123 using spring
Also note that PathVariable is different from requestParam, since pathVariable is part of the URL. The same url using the request parameter will look like www.mydomain.com/order?orderId=123
API DOC
Spring Official Link
coder Nov 06 '13 at 4:10 2013-11-06 04:10
source share