title: How Spring maps URL and where to read more about it
body: <p>I'm new to Spring. I'm trying to learn it by doing instead of reading. So I found some stuff which is confusing. But it works. I want to know why and how?</p>
  
  <pre><code>    @Controller
      @RequestMapping("/ok")
      public class MyController {
  
          @RequestMapping(value = "/ok", method = RequestMethod.GET)
          public ModelAndView findAllAccounts() throws Exception {
              ModelAndView mav = new ModelAndView();
              mav.setViewName("account");
              mav.addObject("someText", "Listing all accounts!");
              return mav;
          }
  
          @RequestMapping(value="/ok/{accountId}", method = RequestMethod.GET)
          public ModelAndView findAccount(@PathVariable int accountId, Model model) {
              ModelAndView mav = new ModelAndView();
              mav.setViewName("account");
              mav.addObject("someText", String.format("Showing account %d", accountId));
              return mav;
          }   
      }
  </code></pre>
  
  <p>For above code I found that.</p>
  
  <p>working Get request url : <a href="http://localhost:8080/ok/" rel="nofollow">http://localhost:8080/ok/</a></p>
  
  <p>working Get request url : <a href="http://localhost:8080/ok/ok/888" rel="nofollow">http://localhost:8080/ok/ok/888</a></p>
  
  <p>But I was expecting url : <a href="http://localhost:8080/ok/ok/" rel="nofollow">http://localhost:8080/ok/ok/</a>  should also work. But it doesn't work. Why? If <a href="http://localhost:8080/ok/ok/888" rel="nofollow">http://localhost:8080/ok/ok/888</a> works why <a href="http://localhost:8080/ok/ok/" rel="nofollow">http://localhost:8080/ok/ok/</a> doesn't work?</p>
  
  <p>Also when I deploy it in tomcat. It only works if named ROOT.war. If I change to XYZ.war, it doesn't work. Why?  </p>