@Bean
@ConfigurationProperties("spring.mvc.viewManager")
public ContentNegotiationManager contentNegotiationManager() {
// 声明contentNegotiationManagerFactory工厂实例,并根据配置参数填充对象。
ContentNegotiationManagerFactoryBean contentNegotiationManagerFactory = new ContentNegotiationManagerFactoryBean();
// 手动填充mediaTypes参数
Map<String, MediaType> mediaTypes = new HashMap<String, MediaType>();
mediaTypes.put("json", MediaType.APPLICATION_JSON_UTF8);
mediaTypes.put("xml", MediaType.APPLICATION_XML);
contentNegotiationManagerFactory.addMediaTypes(mediaTypes);
// 返回contentNegotiationManager对象
return contentNegotiationManagerFactory.getObject();
}
MvcViewConfiguration.java 文件源码
java
阅读 34
收藏 0
点赞 0
评论 0
项目:jeeWe
作者:
评论列表
文章目录