title: HTTP Delete of /a/{id_a}/b/{id_b} becomes /a/{id_a}/b/{id_b}/a/{id_a}/b/{id_b} in SpringMVC
body: <p>I've a servlet in SpringMVC that is working fine in general implementing a REST Api, but I get a strange error when I try to delete a sub-resource.</p>
  
  <p>Saying I have:
  - users as the parent resource
  - addresses as the child resource</p>
  
  <p>If I create (POST), update (PUT) or retrieve (GET) address everything is ok, but when I try to delete it I receive a 404 not found and looking at the log I see </p>
  
  <pre><code> servlet.DispatcherServlet (DispatcherServlet.java:1218) - Rendering view 
  
  [org.springframework.web.servlet.view.InternalResourceView: name 'users/544e6b02300429b462c6b8ea/billing-addresses/4'; URL [users/544e6b02300429b462c6b8ea/billing-addresses/4]] in DispatcherServlet with name 'api-dispatcher'
   view.AbstractView (AbstractView.java:377) - Added model object 'id_user' of type [java.lang.String] to request in view with name 'users/544e6b02300429b462c6b8ea/billing-addresses/4'
   view.AbstractView (AbstractView.java:377) - Added model object 'id_addresses' of type [java.lang.String] to request in view with name 'users/544e6b02300429b462c6b8ea/billing-addresses/4'
   view.InternalResourceView (InternalResourceView.java:207) - Forwarding to resource [users/544e6b02300429b462c6b8ea/billing-addresseses/4] in InternalResourceView 'users/544e6b02300429b462c6b8ea/billing-addresses/4'
   servlet.DispatcherServlet (DispatcherServlet.java:838) - DispatcherServlet with name 'api-dispatcher' processing DELETE request for [/rest-local/rest/users/544e6b02300429b462c6b8ea/billing-addresses/users/544e6b02300429b462c6b8ea/billing-addresses/4]
   handler.AbstractHandlerMethodMapping (AbstractHandlerMethodMapping.java:246) - Looking up handler method for path /users/544e6b02300429b462c6b8ea/billing-addresses/users/544e6b02300429b462c6b8ea/billing-addresses/4
   handler.AbstractHandlerMethodMapping (AbstractHandlerMethodMapping.java:254) - Did not find handler method for [/users/544e6b02300429b462c6b8ea/billing-addresses/users/544e6b02300429b462c6b8ea/billing-addresses/4]
   servlet.DispatcherServlet (DispatcherServlet.java:1114) - No mapping found for HTTP request with URI [/rest-local/rest/users/544e6b02300429b462c6b8ea/billing-addresses/users/544e6b02300429b462c6b8ea/billing-addresses/4] in DispatcherServlet with name 'api-dispatcher'
   servlet.FrameworkServlet (FrameworkServlet.java:991) - Successfully completed request
   servlet.FrameworkServlet (FrameworkServlet.java:991) - Successfully completed request
  </code></pre>
  
  <p>It's like for some reason I don't understand at a some point it append the relative path two times and of course the final path is not handled and I got a 404 Not found.</p>
  
  <p>In the codebase this is the only situation when I try to delete a sub-resource, for all the existing resource DELETE is working, only in this case I see this strange behavior (the code is exactly the same for this resource and for the others).</p>
  
  <p>The server side mapping is:</p>
  
  <pre><code> @RequestMapping(value = "/{id_user}/billing-addresses/{id_address}", method = RequestMethod.DELETE, produces = "application/json")
      public ModelAndView deleteBillingAddress(@PathVariable("id_user") String idUser,
                                               @PathVariable("id_address") String idAddress,
                                               HttpServletResponse httpServletResponse,
                                               Principal principal)
  </code></pre>
  
  <p>And I'm testing it with:</p>
  
  <pre><code>curl -i -X DELETE \
     -H "Content-Type:application/json" \
     -H "Accept-Language:it" \
   'http://localhost:8081/rest-local/rest/users/544e6b02300429b462c6b8ea/billing-addresses/4'
  </code></pre>
  
  <p>Any idea? </p>