Announcement Announcement Module
Collapse
No announcement yet.
@MatrixVariable and (encoded) slashes Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @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
    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.

    Comment

    Working...
    X