MvcViewConfiguration.java 文件源码

java
阅读 34 收藏 0 点赞 0 评论 0

项目:jeeWe 作者:
@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();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号