Spring - Intercept Response Value of Action Method (ResponseBodyAdvice)

Опубликовано: 10 Май 2025
на канале: Cyecize
528
12

To go straight to the point, skip to 7:25.
I suggest watching in 1.25x speed.

In this video I am showing how you can get the returned value of an action method and execute additional logic based on that response.

The reason this cannot be done with interceptor's postHandle method is because we don't have an access to the response value there since it has already been written to the HttpServletResponse.

ResponseBodyAdvice is something like an event which will be executed just before the response value has been written so you can still make changes.

If you want a copy of the project, contact me on facebook or via my email [email protected] and I will send you a link to it or if I upload it to github, I will post the link here.