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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:25:32+00:00 2026-06-07T03:25:32+00:00

I am creating a Spring MVC webapp and I like to use automatic discovery

  • 0

I am creating a Spring MVC webapp and I like to use automatic discovery of components such as controllers.

In my application-context file I put the following tag

<context:component-scan base-package="com.example" />

There is a controller present in com.example.springmvc.controller

@Controller
public class AccountController  {

    @RequestMapping("/account.html")
    public ModelMap showAccount() throws Exception {

        ModelMap modelMap = new ModelMap();
        modelMap.addAttribute("someText", "This is an account");

        return modelMap;
    }

    @RequestMapping("/account.html")
    public ModelMap showAccount(@RequestParam("accountId") int accountId) throws Exception     {

        ModelMap modelMap = new ModelMap();
        modelMap.addAttribute("someText", String.format("This is an account with id %d", accountId));

        return modelMap;
    }

}

When I test by going to localhost:8080/account.html I get a 404, so I must be forgetting something.

When I create a custom mapping in my MVC config file, like below, than it works. At least, then I get an error about ambigious methods in the controller, but that is another problem. At least then it finds the controller.

<bean name="/account.html" class="com.example.springmvc.controller.AccountController"/>

I don’t want to create my mappings in XML, I want to use annotated URL mappings. Could you tell me what I am forgetting here?

  • 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-07T03:25:35+00:00Added an answer on June 7, 2026 at 3:25 am

    To enable annotation-based configuration scanning, add the following to your Spring configuration:

    <mvc:annotation-driven />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a Spring MVC application for the first time. It seems like
In Spring MVC Hibernate application , when i am trying to use properties file
i'm creating a very simple (hello World quality) web application using spring mvc 3.0.
I am creating a custom authentication service in my spring mvc application: @Service public
I am creating an MVC site and would like to use the built in
I am creating a demo application using Spring mvc 3.0.Now i wants to connect
I am attempting to use Spring 3' MVC support for annotated controllers in my
I am creating a Spring MVC Hibernate application using MySQL. Where should I save
I am creating Sample Spring MVC application. In my Controller class I have define
I'm creating a web application using spring mvc. I have started to incorporate the

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.