Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-5636

@RequestMapping matching should be insensitive to trailing slashes

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0 M3
    • Fix Version/s: 3.0 M3
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      For full discussion, see my article: http://grzegorzborkowski.blogspot.com/2009/03/test-drive-of-spring-30-m2-rest-support.html

      Some citations from it:

      "For RESTful web services (...) URLs actually represent virtual directories. This means that common rule "trailing slash doesn't matter" (especially for URL representing "list of resources") should be respected: http://mydomain/restservice/v1/projects address is equivalent to http://mydomain/restservice/v1/projects/ address. If you consider that each project is also the container for its tasks or assignments, then also http://mydomain/restservice/v1/projects/MyProject should be equivalent to http://mydomain/restservice/v1/projects/MyProject/, etc."

      @PathMapping annotation is broken when it comes to handling those trailing slashes:

      "If I mark controller class with @RequestMapping("/projects") then only request without trailing slash will be matched. If trailing slash is appended to the actual request, we get 404 response. What's worse, method-level annotation will not be appended to base URL in this case. So we have to change it to @RequestMapping("/projects/*"). Now methods will work, but if you send request to base url to get list of projects, and forget the slash at the end, you will get 404 response again. That's very bad in my opinion. JAX-RS handles it properly: see JAX-RS's @Path Javadoc."

      For reference: https://jsr311.dev.java.net/nonav/releases/1.0/javax/ws/rs/Path.html

      This issue is related also to SPR-5631.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                arjen.poutsma Arjen Poutsma
                Reporter:
                grzegorzborkowski Grzegorz Borkowski
                Last updater:
                Spring Issuemaster
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  5 weeks ago