在上一篇博客中解析到在InvocableHandlerMethod#doInvoke()中通过反射执行处理方法, 返回值为ModelAndView实例
InvocableHandlerMethod#doInvoke()方法调用链:
在RequestMappingHandlerAdapter#invokeHandlerMethod()方法中主要完成了两件事:
- 执行处理器方法(HandlerMethod)
- 封装并返回ModelAndView实例
(1) 执行处理方法以及封装ModelAndView
@Nullable
protected ModelAndView invokeHandlerMethod(HttpServletRequest request,
HttpServletResponse response, HandlerMethod handlerMethod) throws Exception {
//将Request和Response进行封装
ServletWebRequest webRequest = new ServletWebRequest(request, response);
try {
WebDataBinderFactory binderFactory = getDataBinderFactory(handlerMethod);
ModelFactory modelFactory = getModelFactory(h