title: URL pattern servlet mapping
body: <p>I created hello world example using Spring MVC, but there is one thing I didn't understand in servlet URL mapping, I did the following in web.xml:</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;HelloWeb&lt;/servlet-name&gt;
      &lt;servlet-class&gt;
          org.springframework.web.servlet.DispatcherServlet
      &lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;HelloWeb&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/test/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>now if I want to call the following controller:</p>
  
  <pre><code>@Controller
  @RequestMapping("/hello")
  public class HelloWorld {
      @RequestMapping(method = RequestMethod.GET)
      public String printWelcome(ModelMap model){
          model.addAttribute("message","hello world");
          return "index";
      }
  }
  </code></pre>
  
  <p>it will work using the following link:
  <a href="http://localhost:8080/test/hello" rel="nofollow noreferrer">http://localhost:8080/test/hello</a></p>
  
  <p>but when I change the servlet url-pattern to "/*" and try:
  <a href="http://localhost:8080/hello" rel="nofollow noreferrer">http://localhost:8080/hello</a></p>
  
  <p>it doesn't work, shouldn't it match my servlet ? as * matches everything</p>