Skip to content

ModelAndView.getModel method garbages wasCleared state [SPR-5505] #10177

Closed
@spring-projects-issues

Description

@spring-projects-issues

miceuz opened SPR-5505 and commented

I have two interceptors in my HandlerMapping:

OpenSessionInViewInterceptor and
legacy xt ajax interceptor that utilizes postHandle method and uses ModelAndView returned from controller to get command object - i.e. i can't return null from controller, i need modelAndView in interceptor.

the problem is that i get "javax.servlet.ServletException: ModelAndView [ModelAndView: materialized View is [null]; model is {}] neither contains a view name nor a View object" exceotion in DispatcherServlet after ajax submit event.

My ajax interceptor prepares the response and clears ModelAndView, but WebRequestHandlerInterceptorAdapter, which wraps OpenSessionInViewInterceptor calls getModel() on my modelAndView object. This creates an empty model map in modelNadView:

public ModelMap getModelMap() {
if (this.model == null) {
this.model = new ModelMap();
}
return this.model;
}

and modelAndView.wasCleared() is no longer true.


Affects: 2.5.6

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions