Results 1 to 2 of 2

Thread: @MatrixVariable and (encoded) slashes

Hybrid View

  1. #1
    Join Date
    Dec 2012
    Posts
    2

    Default @MatrixVariable and (encoded) slashes

    Is there any way to configure mappings so that this works?

    I have a controller with
    Code:
        @RequestMapping(value="data{filter}", method=GET)
        public ResponseEntity<Data> getData(@MatrixVariable String title, @RequestParam int page) {
            // ...
        }
    and http://localhost/servlet/data;title=a?page=0 correctly maps to the controller and sets title to "a".

    However I would like it to work when the title contains slashes, in such a way that
    http://localhost/servlet/data;title=a%2fb?page=0 maps to this controller and title is set to "a/b".

    With the default configuration the URL is decoded before mapping so Spring tries to find a controller for data;title=a/b?page=0 and obviously fails.

    I thought that with https://jira.springsource.org/browse/SPR-9098 I can just set urlDecode to false and be happy.
    But this does not work either, with the quite surprising error "org.springframework.web.bind.ServletRequestBindin gException: Missing matrix variable 'title' for method parameter type [java.lang.String]" (only for the "title="a%2fb" case, "title=a" works as before).

  2. #2
    Join Date
    Dec 2012
    Posts
    2

    Default

    Well, my mistake is obvious. The handler mapping with urlDecode set to false also needs removeSemicolonContent set to false.
    Additionally, not appreciating the difference between default DispatcherServlet configuration behaviour and what mvc namespace configuration sets up did not help in debugging the problem.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •