title: Spring - Mapping multiple url-pattern
body: <p>I've asked something few days ago about this, but now came a new problem. My webpage need to access to these urls:</p>
  
  <pre><code>/product/* //(this will be an id or anything else)
  /shopcart/* //(GET, ADD...)
  /*.html
  </code></pre>
  
  <p>I have to access to different HTML pages for some webapp information. At the webapp, you can ask for some products by <code>id</code> and you can see a detailed webpage with all his specs. Also, I have a shopping cart where you can add the products and each time you add a product it will be saved at server's session.</p>
  
  <p>If I want to recover information about products in cart, I access to <code>/shopcart/get</code> and get all information into JSON format. I have this config into my web.xml for that:</p>
  
  <pre><code>&lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;classpath:applicationContext.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;dispatcher&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;dispatcher&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/product/*&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/shopcart/*&lt;/url-pattern&gt;
      &lt;url-pattern&gt;*.html&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>The problem comes that I can access to <code>/product/1</code> to get all specs from product <code>1</code>, but I get the same if I use <code>/shopcart/1</code>. If I specify <code>@RequestMapping("product")</code> (e.g.) into my controller I will have to access to <code>/product/product/1</code> and I don't want that. How can I resolve this problem?</p>
  
  <p>These are my controllers:</p>
  
  <pre><code>@Controller
  public class ProductController {
  
      @RequestMapping("{id}")
      public ModelAndView get(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, @PathVariable String id) {
          Map&lt;String, Object&gt; model = new HashMap&lt;String, Object&gt;();
          //data recovering
          return new ModelAndView("product", model);
      }
  }
  
  @Controller
  public class CartController {
  
      @Autowired
      private JacksonConverter JacksonConverter;
  
      @RequestMapping(value = "/shopcart/get", method = RequestMethod.GET)
      public void get(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
          // data recovering
          httpServletResponse.setContentType("application/json; charset=utf-8");
          httpServletResponse.setStatus(HttpServletResponse.SC_OK);
          httpServletResponse.getWriter().print(json);
      }
  }
  </code></pre>