Spring @PathVariable Annotation Example
![Image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIPVVgChtMUk9GAdI8Vc2u5J5irY8-zueS94u7h__sGyQvDDqJ_XA2P9Iqr4Mx7ntxi9XB9b4iQs2nbGsSR0mr57_1SAz6VZaI6qY3htbilS8BhnM_-uZ7sGUB3Hs9yYEEUjeQ0jVeU01VpYVGVDpGyq1VlveUKesivqV6PLIcgf2c90aJ-JgiaH0OVQ/w400-h156/Untitled%20Diagram.drawio%20(5).png)
In this section we will learn about @ PathVariable Annotation. The @ PathVariable annotation used on a method argument to bind it to the value of a URI template variable. It has the following optional elements: name - name of the path variable to bind to required - tells whether the path variable is required value - alias for name With the @PathVariable annotation, we bind the request URL template path variable to the method variable. For instance, with the /India/Knowledgefactory/ URL, the India value is bind to the country variable and " Knowledgefactory " value to the name variable. @GetMapping ( path = " /users/{country}/{name} " ) public User getUserByCountryAndName( @PathVariable String country, @PathVariable ( name = " name " ) String name) { ........... } The following example creates a Spring Boot web application which uses @PathVariable . The application receives an URL from which it buil