You mean passing the product ID as a URL parameter? Well, the ID could indeed have been passed differently, e.g. as a query parameter or even within a body (not recommended though, especially for GET requests). That's up to developer's choice.
However, by passing the product ID as a URL parameter, we get somewhat neater final URLS, for example: GET https://mywebapp.com/product/12345
(as opposed to: GET https://mywebapp.com/product?id=12345)
I am sorry but what's the plus you are adding while passing id as a param?
You mean passing the product ID as a URL parameter? Well, the ID could indeed have been passed differently, e.g. as a query parameter or even within a body (not recommended though, especially for GET requests). That's up to developer's choice.
However, by passing the product ID as a URL parameter, we get somewhat neater final URLS, for example:
GET https://mywebapp.com/product/12345(as opposed to:
GET https://mywebapp.com/product?id=12345)It's for type-casting.
@Param('id') idwill return a string. Adding a plus converts the string to a number.