Search code examples
spring-mvcjettyurldecode

When does spring mvc decode the query string?


I have a Spring MVC application which is started by Jetty, and there is such a controller:

@RequestMapping(value = "/users/byIds", method = RequestMethod.GET)
public ResponseEntity<String> findUsersWithIds(@RequestParam("ids") String idsJson) throws IOException {
    System.out.println(idsJson);
}

When I issue this url in browser:

http://localhost:8080/users/byIds?ids={%22userIds%22:[%22123456%22]}

I found the idsJson in the method is already decoded:

{"uerIds":["123456"]}

Just wondered when is the query string decoded? Is that done by Spring or Jetty? In some filters?


Solution

  • The servlet container (here Jetty) does that.

    When you call request.getParameter("x") (which Spring MVC is bound to do) it will already have been decoded for you.