January 2018
Intermediate to advanced
414 pages
10h 29m
English
Spring has mapped our new URL to receive a parameter. We have specified that its name will be an id using curly braces on the URL, /customer/{id} in our example. Then, we will create an argument for our method getCustomer that is named exactly id, and we have annotated this method with the annotation @PathVariable and will specify its type to be an Int.
When Spring is autoconfiguring our controller, we will understand this annotation and will map the value pass in the URL to the value required to our method, and it will convert it to the right data type specified. This is a very powerful feature that allows us to easily do mapping on path variables in our methods without requiring any kind of configuration.
Read now
Unlock full access