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 6227325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:11:38+00:00 2026-05-24T09:11:38+00:00

Imagine that I have a Spring MVC controller something like this: @Controller @RequestMapping(/base-url) public

  • 0

Imagine that I have a Spring MVC controller something like this:

@Controller
@RequestMapping("/base-url")
public class MyController{

    //..snip
    @RequestMapping(method=RequestMethod.GET, value="/edit/{id}")
    public String edit(Model model, HttpServletRequest request, Authentication authentication){
        //..snip
    }
}

My question is regarding the inner value parameter to the @RequestMapping annotation at the function level. Is the pre-slash on /edit/{id} required, or does edit/{id} do the job just as well? I would have imagined that the pre-slash would set the request to be absolute, regardless of the class level mapping, but it seems to be ignored.

Is one or the other considered better practice?
In the Spring documentation, they seem to always use the pre-slash. Are there any practical benefits to doing that?

Thanks,

idb.

  • 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-24T09:11:39+00:00Added an answer on May 24, 2026 at 9:11 am

    According to the spring documentation, having a class level @RequestMapping annotation implies that all method level @RequestMappings will be relative to that of the class’.

    It might be nice however, to have the ability to override the relative mappings in some rare cases.

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

Sidebar

Related Questions

Imagine a code like this one: @RequestMapping(value=/users, method=RequestMethod.GET) public String list(Model model) { ...
ok imagine that we have text like this String s=123 45678 91011122314 1516; now
Imagine this case where I have an object that I need to check a
Let's say I have a PHP Model-View-Controller framework that maps an address like http://example.com/admin/posts/edit/5
I have developed an application with Spring MVC that deals with bulk data insert/update.
I want to convert a string to a class name. Imagine that I have
In my code I have often situations like this: public void MyMethod(string data) {
Imagine that you have a simple site with only 2 pages: login.aspx and secret.aspx.
Imagine that you have several links on a page. When you clicked, a div
Is it normal to modify setter arguments? Let's imagine that we have setString method.

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.