Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

The @PathVariable annotation

Pragya Keshap answered on February 19, 2023 Popularity 3/10 Helpfulness 1/10

Contents


More Related Answers

  • What is @pathVariable?

  • The @PathVariable annotation

    0

    @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.

    Popularity 3/10 Helpfulness 1/10 Language whatever
    Source: Grepper
    Tags: whatever
    Link to this answer
    Share Copy Link
    Contributed on Feb 19 2023
    Pragya Keshap
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.