Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7540985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:46:36+00:00 2026-05-30T07:46:36+00:00

This might be a simple question for those who know Spring, but since I

  • 0

This might be a simple question for those who know Spring, but since I am a newbie, I will ask it anyway.

I am going through some Spring code and I am not able to understand the following-

 @RequestMapping(value="/{id}") 
 public void show(@PathVariable("id") long id, Model model) {...}

The comment for this section of the code is – “When using URI Templates, access parameters using the @PathVariable annotation.

Now earlier, I came across code like

 @RequestMapping(value="/url/path") 
 public String list(Model model) {...}

By this, I understand that whenever the url “/url/path” is encountered, the list() method will be called, but I am not able to make sense of the former annotation. What does it mean?

Also, the next line says @PathVariable annotations can be limited via regular expressions

 @RequestMapping(value="/{id}")
 public void show(@PathVariable("id:[\\d]*") String idl) {...} // will match only numberic IDs

What does it mean?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:46:38+00:00Added an answer on May 30, 2026 at 7:46 am

    16.3.2.2 URI Template Patterns

    URI templates can be used for convenient access to selected parts of a URL in a @RequestMapping method.

    For example, the URI Template http://www.example.com/users/{userId} contains the variable userId. Assigning the value fred to the variable yields http://www.example.com/users/fred.

    In Spring MVC you can use the @PathVariable annotation on a method argument to bind it to the value of a URI template variable:

    So, in your example:

    @RequestMapping(value="/{id}") 
    public void show(@PathVariable("id") long id, Model model) {...}
    

    This will extract the part of the URL represented by {id}, and bind it to the id method parameter, e.g. the path /42 will bind 42 to id.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be a simple question, but i can't seem to grasp it. I
This might be a simple question but I'm just picking this up so please
There might be a really simple solution to this question, but i just don't
This might be a way to simple question, but I seem to miss the
The title of this question might be confusing but the problem is simple. I'm
I know this question might be repeated many times but would really appreciate any
This question might be asked before but I couldn't solve my problem with those
This might be simple but I am new to Oracle. I am using Oracle
This might be a simple answer, but I am having some issues writing this
This might seem ridiculously simple, but I've been getting all kinds of error depending

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.