springboot学习11

1、视图内容协商
交互流程:

1、ContentNegotiationConfigurer- - -关联- - ->ContentNegotiationManagerFactoryBean
2、ContentNegotiationConfigurer - - - 配置 - - ->ContentNegotiationStrategy 实现(PathExtensionContentNegotiationStrategy、ParameterContentNegotiationStrategy、FixedContentNegotiationStrategy、HeaderContentNegotiationStrategy、ServletPathExtensionContentNegotiationStrategy)
3、ContentNegotiationStrategy 实现 - - - 添加策略- - -> ContentNegotiationManagerFactoryBean
4、ContentNegotiationManagerFactoryBean - - - 创建- - -> ContentNegotiationManager
5、ContentNegotiationViewResolver- - - Bean 关联 - - - >ContentNegotiationManager
6、ContentNegotiationViewResolver - - -  Bean关联 - - ->ViewResolver Bean 列表(InternalResourceViewResolver、ThymeleafViewResolver 、。。。)
7、Client - - - 请求- - ->DispatchServlet
8、DispatchServlet - - -解析View - - -> ContentNegotiationViewResolver
9、ContentNegotiationViewResolver  - - - 策略匹配- - -> ViewResolver Bean 列表 (InternalResourceViewResolver、ThymeleafViewResolver 、。。。)
10、ContentNegotiationViewResolver - - -  最佳匹配View - - ->DispatchServlet
11、DispatchServlet - - - View渲染 - - -> Client

主要组件:

视图解析
    ContentNegotiatingViewResolver
          InternalResourceViewResolver
          BeanNameViewResolver
          ThymeleafViewResolver
配置策略
	配置 Bean: WebMvcConfigurer
	配置对象: ContentNegotiationConfigurer
策略管理
	Bean: ContentNegotiationManager
	FactoryBean : ContentNegotiationManagerFactoryBean
策略实现
    ContentNegotiationStrategy
		固定 MediaType : FixedContentNegotiationStrategy 
		"Accept" 请求头: HeaderContentNegotiationStrategy 
		请求参数: ParameterContentNegotiationStrategy
		路径扩展名: PathExtensionContentNegotiationStrategy
                                      

2、多视图内容协商

视图处理器协商
   ContentNegotiatingViewResolver
		BeanNameViewResolver
		InternalResourceViewResolver Content-Type : text/xml;charset=UTF-8 
		ThymeleafViewResolver Content-Type : text/html;charset=UTF-8
	
最佳 View 匹配规则
	ViewResolver 优先规则
		自定义 InternalResourceViewResolver 
		ThymeleafViewResolver
		默认 InternalResourceViewResolver 
	MediaType 匹配规则
		Accept 头策略
		请求参数策略

3、视图组件自动装配

自动装配 Bean
	视图处理器
		InternalResourceViewResolver
		BeanNameViewResolver
		ContentNegotiatingViewResolver 
		ViewResolverComposite 
		ThymeleafViewResolver ( Thymeleaf 可用)
	
	内容协商
	      ContentNegotiationManager
	外部化配置
	      WebMvcProperties
	      WebMvcProperties.Contentnegotiation
	      WebMvcProperties.View                  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值