摘要:
会注入如下classConfigurationClassPostProcessor1、遍历所有bean,如果class有注解Configuration或Component或class的方法有Bean2、利用ConfigurationClassParser 解析 class,把bean 加载到 容器中AutowiredAnnotationBeanPostProcessor1、把autowired注解的method或field注入到bean中RequiredAnnotationBeanPostProcessor1、检查如果 有Required注解,但是没有注入依赖,那么将抛错CommonAnnot 阅读全文
摘要:
http内容转换器默认添加ByteArrayHttpMessageConverterStringHttpMessageConverterResourceHttpMessageConverterSourceHttpMessageConverterAllEncompassingFormHttpMessageConverter根据jar包添加MappingJacksonHttpMessageConverterMappingJackson2HttpMessageConverterJaxb2RootElementHttpMessageConverterRssChannelHttpMessageConve 阅读全文
摘要:
常用接口ApplicationContextAware void setApplicationContext(ApplicationContext applicationContext)BeanNameAware void setBeanName(String name)InitializingBean void afterPropertiesSet()DisposableBean void destroy()BeanDefinitionRegistryPostProcessor void postProcessBeanDefinitionRegistry(BeanDefinitionRegi 阅读全文
摘要:
会注入如下classSet beanDefinitions = ClassPathBeanDefinitionScanner.doScan(package);加载目录下面有Component、Controller.class、Repository.class、Service.class注解的class这个包含了功能 阅读全文
摘要:
返回处理类ModelAndViewMethodReturnValueHandler 处理返回类型为ModelAndView,如果ModelAndView的view是String类型,则mavContainer.setViewName(viewName); 否则mavContainer.setView(ModelAndView.getView()); 最后mavContainer.addAllAttributes(mav.getModel());ModelMethodProcessor处理返回类型为Model,执行 mavContainer.addAllAttributes(((Model) . 阅读全文
摘要:
参数解析类RequestParamMethodArgumentResolver处理类型: 1、包含注解RequestParam,但不处理参数类型为Map,且不包含value值 2、参数类型为MultipartFile,或javax.servlet.http.Part的类型处理方式: 1、如果参数类型为MultipartFile,返回MultipartFile 2、如果参数类型为List,返回List 3、如果参数类型为javax.servlet.http.Part,返回Part 4、否则返回request.getParameter("key") RequestParamMa 阅读全文
摘要:
DispatcherServlet处理流程1、根据URL找到对应的hander2、执行HandlerExecutionChain.applyPreHandle(processedRequest, response),实际是执行HandlerInterceptor的preHandle方法,如果执行返回false,至请求完成3、执行HandlerAdapter.hander a、如果是注解方式,执行RequestMappingHandlerAdapter.handleInternal 阅读全文