Answer the question
In order to leave comments, you need to log in
How to get RequestBody and ResponseBody from HttpServletRequest and HttpServletResponse objects?
What would you like to implement?
Logging of each request + request body + response body to the database.
The project uses Spring MVC, and therefore it was decided to do logging in the afterCompletion method of our HandlerInterceptor implementation.
Question: how to correctly get the request body and object body from the HttpServletRequest and HttpServletResponse objects that are passed to the afterCompletion method?
Answer the question
In order to leave comments, you need to log in
In the standard way - no way.
The request body is formed based on the HTTP request data. Based on the response body, respectively, an HTTP response is formed. Various implementations of the HttpMessageConverter interface do this.
If you need - write your own implementations. You can simply expand existing ones. If you don't feel like it, you can try using interception through AOP.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question