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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:28:46+00:00 2026-05-28T08:28:46+00:00

I am playing with spring MVC 3.1 and testing different features. I wanted to

  • 0

I am playing with spring MVC 3.1 and testing different features. I wanted to verify following statement taken from @RequestMapping#value doc

If you have a single default method (without explicit path mapping), then all requests without a more specific mapped method found will be dispatched to it. If you have multiple such default methods, then the method name will be taken into account for choosing between them

So I created following controller with multiple default handler methods.

@Controller
@RequestMapping("/book")
public class BookController {

    @RequestMapping
    public @ResponseBody String greet() {
        return "Hi Book!";
    }

    @RequestMapping
    public @ResponseBody String meet() {
        return "Nice to meet you Book!";
    }
}

Here is web application context configuration

<beans ....>
<!-- Use @Component annotations for bean definitions -->
  <context:component-scan base-package="com.botreeconsulting.lms.web"/>

  <!-- Use @Controller annotations for MVC controller definitions -->
  <mvc:annotation-driven />

  <bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">

        <property name="prefix">
            <value>/WEB-INF/views/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
   </bean>

</beans>

But it seems I messed up something as it is giving me following error at the time of deployment:

java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'bookController' bean method 
public java.lang.String com.botreeconsulting.lms.web.BookController.meet()
to {[/book],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'bookController' bean method
public java.lang.String com.botreeconsulting.lms.web.BookController.greet() mapped.

Now the question is does this controller models what is written in the document? I feel that I didn’t get it properly. Please guide me to model the controller to match the statement about multiple default handlers.

Thanks, Amit

  • 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-28T08:28:47+00:00Added an answer on May 28, 2026 at 8:28 am

    If you have a controller as given below, all requests other than /book/edit will be directed to mydefault() while /book/edit will be sent to meet().

    @Controller
    @RequestMapping("/book")
    public class BookController {
    
        @RequestMapping
        public @ResponseBody String mydefault() {
            return "Hi Book!";
        }
    
        @RequestMapping("/edit")
        public @ResponseBody String meet() {
            return "Nice to meet you Book!";
        }
    }
    

    In your sample you have two methods without explicit path mapping.

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

Sidebar

Related Questions

I've been playing around with Spring Security a bit and noticed the following oddity.
I've been playing around with different aspects of MVC for some time now, and
I have the following sql prepared statement: SELECT * FROM video WHERE video_name LIKE
Following various example configurations from Spring documentation as well as some forums on the
I am new to Spring.NET and am just playing around trying different things out.
In Spring MVC when placing an object in the view model like so: public
I'm playing around with writing some simple Spring-based web apps and deploying them to
I'm pretty new to the Spring Framework, I've been playing around with it and
I'm working on converting an old Struts 1.x application to Spring MVC and in
I'm playing around with Razor + MVC 3 and have a really simple scenario...

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.