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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:33:33+00:00 2026-05-13T17:33:33+00:00

I am using Spring MVC to develop a Java webapp. I have a setup

  • 0

I am using Spring MVC to develop a Java webapp. I have a setup as follows: 2 pages of the site are responsible for rendering similar content. One of the pages simply renders the items slightly differently (and hence would need a different view), and pulls the data slightly differently (with a limit on the query instead of pulling all the items).

My question is: would the best approach for this be to implement 2 separate controllers to handle each of these pages, or would it be better to use a single controller? If the answer is to use a single controller, how can I find out from inside the controller from what page the request came from (so that I can call the appropriate service and view)? Thanks

  • 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-13T17:33:34+00:00Added an answer on May 13, 2026 at 5:33 pm

    With Spring 2.5+ annotated controllers, the difference between having one controller or two controllers is not especially relevant.

    For example, say you have a controller class like this:

    @Controller
    public class MyController {
    
       @RequestMapping ("/pageA");
       public String handlePageA() {
          .. do stuff
       }
    
       @RequestMapping ("/pageB");
       public String handlePageB() {
          .. do stuff
       }
    }
    

    It should be obvious how this works. You get the benefit of one controller, with two handler methods, one for each “page”.

    There really is no reason to use pre-2.5 controllers any more. You can use the new style alongside the old one, so even legacy pre-2.5 apps can use the new style after an upgrade.

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

Sidebar

Related Questions

I am using spring mvc. I have 3 pages in my site (actually the
I am using spring mvc in my application,when i created user i have to
I'm using spring MVC, and I have a custom authentication/security system that I had
I'm creating a web application using spring mvc. I have started to incorporate the
I have configured in following way that spring MVC app using Spring 3.1.1.RELEASE web.xml
I've have been using Mono Develop 2.8 on a to make an ASP MVC
I’m trying to develop a Spring 3 MVC application using the Springsource Tool Suite/Eclipse
I am using spring mvc and spring security. In my security-app-context.xml I have: <authentication-manager>
I am using spring MVC 3. I have been trying to access the attributes
I have to develop a Spring MVC project. This give user the possibility to

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.