title: In Spring MVC, how can I get @RequestMapping to work?
body: <p>In Spring 3 MVC, I have a controller that I call RolesController, and it has methods such as displayRoles() for displaying a list of roles, saveRole(), and deleteRole().  </p>
  
  <p>Currently, I'm successfully using @RequestMapping annotations to route /settings/roles/ to call the displayRoles() method, /settings/roles/save/ to call the saveRole() method, and so on.</p>
  
  <p>My code is below, and it works.</p>
  
  <pre><code>@Controller
  public class RolesController {
  
      @Transactional
      @RequestMapping(value = {"settings/roles/save"}, method = {RequestMethod.POST})
      public ModelAndView saveRole(details removed){
          //details removed
      }
  
      @RequestMapping(value = {"settings/roles/delete"}, method = {RequestMethod.POST})
      public ModelAndView deleteRole(details removed){
         //details removed
      }
  
      @RequestMapping(value = {"settings/roles"}, method = RequestMethod.GET)
      public ModelAndView displayRoles(details removed){
        //details removed
      }
  
  }
  </code></pre>
  
  <p>There are 2 problems that I haven't been able to fix, though:</p>
  
  <ol>
  <li><strong>I've been unable to map the parent directory <code>/settings/</code> to call the displayRoles() method.</strong> If I change the mapping of the displayRoles method to <code>@RequestMapping(value = {"settings","settings/","settings/roles"}, method = RequestMethod.GET)</code> and then rebuild and browse to /settings in the URL, I get a 404 error. Why can't I map to the "settings" parent folder?</li>
  <li><strong>Trailing slashes in the URL seem to be required.</strong> E.g., going to settings/roles/ works, but visiting settings/roles results in a 404 Page Not Found error.</li>
  </ol>
  
  <p><strong>What am I doing wrong?  Thanks!  -Ryan</strong>
  <hr/>
  P.S. Here is some extra info... in case this helps:</p>
  
  <p>In my applicationContext-mvc.xml file, I have (among other code):</p>
  
  <pre><code>&lt;!-- Maps request paths to @Controller classes; e.g. a path of /login looks for a controller named LoginController --&gt;
  &lt;bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"&gt;
      &lt;property name="order" value="1" /&gt;
  &lt;/bean&gt;      
  &lt;!-- If no @Controller match, look for @RequestMapping match--&gt;
  &lt;bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"&gt;
      &lt;property name="order" value="2" /&gt;
      &lt;property name="defaultHandler"&gt;
          &lt;!-- If no @RequestMapping match, map path to a view to render; e.g. the "/intro" path would map to the view named "intro" --&gt;
          &lt;bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController" /&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>
      
          
      </p>