处理器适配器的详细处理过程
当把需要的处理器和适配器找到之后,下面就开始执行具体的处理过程了,通过下述代码进行调用:
1 | mv = ha.handle(processedRequest, response, mappedHandler.getHandler()); |
找到RequestMappingHandlerAdapter的类中
1 |
|
1、mav = invokeHandlerMethod(request, response, handlerMethod);
1 |
|
1、WebDataBinderFactory binderFactory = getDataBinderFactory(handlerMethod);
1 | private WebDataBinderFactory getDataBinderFactory(HandlerMethod handlerMethod) throws Exception { |
2、ModelFactory modelFactory = getModelFactory(handlerMethod, binderFactory);
1 | private ModelFactory getModelFactory(HandlerMethod handlerMethod, WebDataBinderFactory binderFactory) { |
3、ServletInvocableHandlerMethod invocableMethod = createInvocableHandlerMethod(handlerMethod);
1 | protected ServletInvocableHandlerMethod createInvocableHandlerMethod(HandlerMethod handlerMethod) { |
4、modelFactory.initModel(webRequest, mavContainer, invocableMethod);
1 | public void initModel(NativeWebRequest request, ModelAndViewContainer container, HandlerMethod handlerMethod) |
5、invocableMethod.invokeAndHandle(webRequest, mavContainer);
1 | public void invokeAndHandle(ServletWebRequest webRequest, ModelAndViewContainer mavContainer, |
if (!this.resolvers.supportsParameter(parameter))
1 |
|
args[i] = this.resolvers.resolveArgument(parameter, mavContainer, request, this.dataBinderFactory);
1 | public Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer, |
this.returnValueHandlers.handleReturnValue(
returnValue, getReturnValueType(returnValue), mavContainer, webRequest);
1 |
|
6、getModelAndView(mavContainer, modelFactory, webRequest);
1 |
|