@PathVariable helps you to create the dynamic URIs. The @PathVariable annotation allows you to map Java parameters to a path parameter. It works with @RequestMapping, where the placeholder is created in a URI, and then the same placeholder name is used either as a PathVariable or a method parameter, as you can see in the CalculationController class method sqrt(). Here, the value placeholder is created inside the @RequestMapping annotation and the same value is assigned to the value of the @PathVariable.
The sqrt() method takes the parameter in the URI in place of the request parameter, for example, http://localhost:8080/calculation/sqrt/144. Here, the 144 value is passed as the path parameter and this URL should return the square root of 144, which is 12.
To use the basic check in place, we use the regular expression, "^-?+\\d+\\.?+\\d*$", to allow only valid numbers in parameters.