Issue
Logic I have to implement is logging all requests with body served to DB.
So I decided to use: afterCompletion
method of HandlerInterceptor
.
There are two parameters passed to this method HttpServletRequest
and HttpServletResponse
among the others.
Question is: how to get RequestBody
and ResponseBody
from supplied objects?
As far as I know at Controller we can use @RequestBody
and @ResponseBody
. Can I reuse them at HandlerInterceptor
?
Solution
As far as I know, RequestBody
and ResponseBody
can be read only once. So you should not read them in an Interceptor
.
Here's some explanation.
Answered By - marcellsimon
Answer Checked By - Candace Johnson (JavaFixing Volunteer)