diff --git a/mvc/src/main/java/webmvc/org/springframework/web/servlet/DispatcherServlet.java b/mvc/src/main/java/webmvc/org/springframework/web/servlet/DispatcherServlet.java index 96acf54f6c..40134bf4e9 100644 --- a/mvc/src/main/java/webmvc/org/springframework/web/servlet/DispatcherServlet.java +++ b/mvc/src/main/java/webmvc/org/springframework/web/servlet/DispatcherServlet.java @@ -52,7 +52,6 @@ protected void service(final HttpServletRequest request, final HttpServletRespon private void render(final ModelAndView modelAndView, final HttpServletRequest request, final HttpServletResponse response) throws Exception { - final View view = modelAndView.getView(); - view.render(modelAndView.getModel(), request, response); + modelAndView.render(modelAndView.getModel(), request, response); } } diff --git a/mvc/src/main/java/webmvc/org/springframework/web/servlet/ModelAndView.java b/mvc/src/main/java/webmvc/org/springframework/web/servlet/ModelAndView.java index ff8e24553f..90debfa6ea 100644 --- a/mvc/src/main/java/webmvc/org/springframework/web/servlet/ModelAndView.java +++ b/mvc/src/main/java/webmvc/org/springframework/web/servlet/ModelAndView.java @@ -1,5 +1,7 @@ package webmvc.org.springframework.web.servlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -19,6 +21,11 @@ public ModelAndView addObject(final String attributeName, final Object attribute return this; } + public void render(Map model, HttpServletRequest request, HttpServletResponse response) + throws Exception { + view.render(model, request, response); + } + public Object getObject(final String attributeName) { return model.get(attributeName); }