You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, if you try and use @ResponseBody and HandlerInterceptor together, you don't get the expected behaviour.
Specifically, the @ResponseBody is written and committed by ServletHandlerMethodInvoker before HandlerInterceptor.postHandle is called. I would have expected the order to be similar to if I had omitted the @ResponseBody and used a MarshallingView instead, i.e.
HandlerInterceptor.preHandle
(handler is invoked)
HandlerInterceptor.postHandle
(response is written)
HandlerInterceptor.afterCompletion
With @ResponseBody, the 3rd and 4th steps are reversed.
Looking at the code, this wouldn't seem an easy refactoring to make, but could it be done?
#15486 scheduled for 4.1 RC1 should address this concern by providing an additional interception point.
Since @ResponseBody relies on use of HttpMessageConverter's that write to the response immediately after the controller method is invoked. As a consequence it is too late for HandlerInterceptor's postHandle to get involved.
Uh oh!
There was an error while loading. Please reload this page.
Kenny MacLeod opened SPR-7897 and commented
Currently, if you try and use
@ResponseBody
andHandlerInterceptor
together, you don't get the expected behaviour.Specifically, the
@ResponseBody
is written and committed byServletHandlerMethodInvoker
beforeHandlerInterceptor.postHandle
is called. I would have expected the order to be similar to if I had omitted the@ResponseBody
and used aMarshallingView
instead, i.e.HandlerInterceptor.preHandle
HandlerInterceptor.postHandle
HandlerInterceptor.afterCompletion
With
@ResponseBody
, the 3rd and 4th steps are reversed.Looking at the code, this wouldn't seem an easy refactoring to make, but could it be done?
Affects: 3.0.5
Issue Links:
@ResponseBody
("is superseded by")2 votes, 3 watchers
The text was updated successfully, but these errors were encountered: