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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:24:32+00:00 2026-05-28T02:24:32+00:00

I would like to have URL mappings that I’m having with spring framework like

  • 0

I would like to have URL mappings that I’m having with spring framework like below in standard servlet web.xml configuration.

 @RequestMapping(value="/students/{username}", method=RequestMethod.GET)
  public String deleteSpitter(@PathVariable String username) {
    ...
    ...
  }

I would like URL mappings like these two:

/students/Mike

/students/John

to be mapped to same servlet where I can also read “Mike” and “John” as parameters somehow. If it can be extended to more than one level like the example below it could be very much useful for me:

/students/{schoolname}/{studentname}
like:

/students/mcgill/mike

/students/ubc/john

  • 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-28T02:24:33+00:00Added an answer on May 28, 2026 at 2:24 am

    You can map a standard servlet to a wildcard path and access the pathInfo part of the request using the HttpServletRequest.getPathInfo() method.

    The servlet should get the path info like this

    package com.acme;
    
    public class TestServlet extends HttpServlet {
    
        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            String info = request.getPathInfo();
        }
    
    }
    

    and you should map the servlet in your web.xml like this

    <servlet>
        <servlet-name>test-servlet</servlet-name>
        <servlet-class>com.acme.TestServlet</servlet-class>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>test-servlet</servlet-name>
        <url-pattern>/test/*</url-pattern>
    </servlet-mapping>
    

    If you request the URL ‘/test/mcgill/mike’ the path info will be ‘/mcgill/mike’. Parsing the path info is up to you.

    If you work with a Java EE 6 compliant container you should also take a look at the JAX-RS specification to build RESTful web services.

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

Sidebar

Related Questions

I have a REST web service that I would like to take a URL
I have a URL that returns a HTTP 302 redirect, and I would like
I have a spring app with one servlet that has url-mapping of *.html. Everything
I hit the maximum url-patterns that one can have in the web.xml and I
Imagine that I have a Spring MVC controller something like this: @Controller @RequestMapping(/base-url) public
I am looking for a way to have complex URL mappings that would depend
I have pom.xml that contains defined values. I would like to use one of
i would like a simple help... i have a url like this: example.com/profile.php?id= &
I have a small problem with url rewriting on apache. I would like it
I have a problem that I would like have solved via a SQL query.

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.