I have a plain controller class extends AbstractController
that I'm plugging into Spring's handler mapping mechanism, by creating a new SimpleUrlHandlerMapping
bean.
In my class I need to read the raw POST data, even when the Content-Type is application/x-www-form-urlencoded
. This is somewhat tricky in the Servlet specification, because in order to do that, you need to call request.getInputStream()
or request.getReader()
before you access any of the request.getParameter*()
methods. Otherwise, the latter will consume the input stream and it will not be available anymore.
In my class I'm not calling any of the getParameter*()
methods, but I'm still seeing an empty request body when the Content-Type is application/x-www-form-urlencoded
. Which means that Spring is calling one of the getParameter*()
methods before it handles control over to my class.
Which class is doing that and how can I prevent it?
(Note to overzealous editors: this question is specific to Spring Boot. It is not a duplicate of other "raw POST data" questions.)