Skip to content

Make HandlerInterceptor play nice with @ResponseBody [SPR-7897] #12553

@spring-projects-issues

Description

@spring-projects-issues

Kenny MacLeod opened SPR-7897 and commented

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?


Affects: 3.0.5

Issue Links:

2 votes, 3 watchers

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions