title: Spring MVC 3.1: Trouble with url mapping
body: <p>I'm new to Spring MVC framework, having some trouble with basic URL mapping using two different controllers. I'm using @Controller and @RequestMapping.</p>
  
  <p>The following results in 404 error for both /people and /accounts.</p>
  
  <p>Here is my Spring MVC 3.1 setup:</p>
  
  <p><strong>index.jsp</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;t-diggity&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;integration&lt;/h1&gt;
      &lt;a href="/people/"&gt;Contact List&lt;/a&gt;&lt;br&gt;
      &lt;a href="/accounts/"&gt;Account List&lt;/a&gt;&lt;br&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>web.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns="http://java.sun.com/xml/ns/javaee"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
       version="2.5"&gt;
  
  &lt;display-name&gt;t-diggity&lt;/display-name&gt;
  
  &lt;filter&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
      &lt;init-param&gt;
              &lt;param-name&gt;contextAttribute&lt;/param-name&gt;
              &lt;param-value&gt;org.springframework.web.servlet.FrameworkServlet.CONTEXT.spring&lt;/param-value&gt;
          &lt;/init-param&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
  
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;spring&lt;/servlet-name&gt;
          &lt;servlet-class&gt;
              org.springframework.web.servlet.DispatcherServlet
          &lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;classpath:applicationContext.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;spring&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/people/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;spring&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/assets/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;spring&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/accounts/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p><strong>controller # 1: PersonController.java</strong></p>
  
  <pre><code>@Controller
  @RequestMapping("/people/")
  public class PersonController {
  
      @Autowired
      private PersonService personService;
  
      @RequestMapping("/")
      public String listPeople(Map&lt;String, Object&gt; map) 
      {
          map.put("person", new Person());
          map.put("peopleList", personService.listPeople());
          return "people";
      }
  
      @RequestMapping(value = "/addPerson", method = RequestMethod.POST)
      public String addPerson(@ModelAttribute("person") Person person, BindingResult result
      {
          personService.addPerson(person);
          return "redirect:/people/";
      }
  
      @RequestMapping("/delete/{personId}")
      public String deletePerson(@PathVariable("personId") String personId) 
      {
          personService.removePerson(personId);
          return "redirect:/people/";
      }
  }
  </code></pre>
  
  <p><strong>controller #2: AccountController.java</strong></p>
  
  <pre><code>@Controller
  @RequestMapping("/accounts")
  public class AccountController {
  
      @Autowired
      private AccountService accountService;
  
      @RequestMapping("/")
      public String listAccounts(Map&lt;String, Object&gt; map) 
      {
          map.put("account", new Account());
          map.put("accountList", accountService.listAccounts());
          return "accounts";
      }
  
      @RequestMapping(value = "/addAccount", method = RequestMethod.POST)
      public String addPerson(@ModelAttribute("account") Account account, 
                              BindingResult result) 
      {
          accountService.addAccount(account);
          return "redirect:/accounts/";
      }
  
      @RequestMapping("/delete/{accountId}")
      public String deleteAccount(@PathVariable("accountId") String accountId) {
          accountService.removeAccount(accountId);
          return "redirect:/accounts/";
      }
  
  }
  </code></pre>
  
  <p>I am hoping my error is a minor one, I'm new to URL mapping so it likely is minor...  I'd appreciate any coaching, thanks in advance.</p>