When you have a handler method that simply returns a String
, that String
is considered a view name. With a prefix of forward
, Spring will get a RequestDispatcher
for the specified path and forward to it. Part of that process will include taking the Model
from the ModelAndView
created for that request handling cycle and putting all its attributes into the HttpServletRequest
attributes.
The Servlet container will take the RequestDispatcher#forward(..)
and again use your DispatcherServlet
to handle it. Your DispatcherServlet
will create a new ModelAndView
with a new Model
for this handling cycle. Therefore this Model
doesn't contain any of the attributes from before but the HttpServletRequest
attributes do.
In your case, this
modelMap.put(WEBPAGE_MODEL_KEY, prepareModel(webpage));
will end up being in
HttpServletRequest request = ...;
request.getAttribute(WEBPAGE_MODEL_KEY);