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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:35:11+00:00 2026-06-17T12:35:11+00:00

I am trying to construct a clean URL mapping inside my MVC application and

  • 0

I am trying to construct a clean URL mapping inside my MVC application and I found alot of common urls like:

/SITE/{city}-{language}/user/{userId}

@RequestMapping(value = "/{city}-{language}/user/{userId}", 
         method = RequestMethod.GET)
public String user(@PathVariable String city, 
                   @PathVariable String language, 
                   @PathVariable String userId, 
                   Model model) {}

/SITE/{city}-{language}/comment/{userId}-{commentId}

@RequestMapping(value = "/{city}-{language}/comment/{userId}-{commentId}",
         method = RequestMethod.GET)
public String comment(@PathVariable String city,
                      @PathVariable String language, 
                      @PathVariable String userId,
                      @PathVariable String commentId, 
                      Model model) {}

Is there a way to auto bind the city and the language to the model automatically instead of @PathVariable of Filters, I think it make since as it will reduce the @RequestMapping function paramets count.

  • 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-06-17T12:35:11+00:00Added an answer on June 17, 2026 at 12:35 pm

    I make a work around that serves my need, I created an abstract base class that maps the common params.

    public abstract class AbstractController {
    
        @ModelAttribute("currentCity")
        public CityEntity getCurrentCity(@PathVariable CityEntity city) {
            //CityEntity via a converter class
            return city;
        }
    
        @ModelAttribute("language")
        public String getLanguage(@PathVariable String language) {
            return language;
        }
    }
    

    and now the two common attributes will be available in the model object

    @RequestMapping(value = "/{city}-{language}")
    public class UserController extends AbstractController {
    
          @RequestMapping(value = "/user/{userId}", method = RequestMethod.GET)
          public String user(@PathVariable String userId, 
                   Model model) {...}
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to construct a TreeView from a Menu. My Code is like
I'm trying to clean up my URIs on a multi-language CI site by changing
I am using Ninject in my MVC application and am trying to implement a
Trying to construct a Request with Network.HTTP.Conduit package. The instructions are: The constructor for
Am trying to construct a simple update query in my model class Model_DbTable_Account extends
I am trying to construct a customized map in raphaeljs , in this i
I am trying to construct a deeply nested associative array but i don't know
Possible Duplicate: Trying to construct a tableview with a navigation bar at top I
I'm trying to construct a regular expression that would extract the name of the
I'm trying to construct a datatype that is essentially a binary tree whose: each

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.