How do you access RequestBody in HandlerInterceptorAdapter?

I tried to pull the body out of request.getReader() , but it has already been read.

How can I get my hand from the request object inside the interceptor?

+4
source share
1 answer

As you say, the request body can only be read with Reader once. This does not apply to interceptors, but for all servlet API users.

If you need to access the body a second time, you need to save the data somewhere, for example, in the request attribute (using request.setAttribute() and request.getAttribute() ).

How and where you do it, it depends on your interceptor, and you did not tell us anything about your particular case.

0
source

All Articles