当前位置: 首页>>代码示例>>Java>>正文


Java MappingJackson2HttpMessageConverter.setSupportedMediaTypes方法代码示例

本文整理汇总了Java中org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.setSupportedMediaTypes方法的典型用法代码示例。如果您正苦于以下问题:Java MappingJackson2HttpMessageConverter.setSupportedMediaTypes方法的具体用法?Java MappingJackson2HttpMessageConverter.setSupportedMediaTypes怎么用?Java MappingJackson2HttpMessageConverter.setSupportedMediaTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.http.converter.json.MappingJackson2HttpMessageConverter的用法示例。


在下文中一共展示了MappingJackson2HttpMessageConverter.setSupportedMediaTypes方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureMessageConverters

import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; //导入方法依赖的package包/类
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    /*FastJsonHttpMessageConverter4 converter = new FastJsonHttpMessageConverter4();
    FastJsonConfig config = new FastJsonConfig();
    config.setSerializerFeatures(SerializerFeature.WriteMapNullValue,//保留空的字段
            SerializerFeature.WriteNullStringAsEmpty,//String null -> ""
            SerializerFeature.WriteNullNumberAsZero);//Number null -> 0
    converter.setFastJsonConfig(config);
    converter.setDefaultCharset(Charset.forName("UTF-8"));*/

    MappingJackson2HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter();
    List<MediaType> mediaTypes = new ArrayList<>();
    mediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
    mediaTypes.add(MediaType.TEXT_HTML);
    jacksonConverter.setSupportedMediaTypes(mediaTypes);
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    jacksonConverter.setObjectMapper(objectMapper);
    converters.add(jacksonConverter);
    //converters.add(responseBodyConverter());
}
 
开发者ID:pandboy,项目名称:pingguopai,代码行数:22,代码来源:WebMvcConfigurer.java

示例2: getRestTemplate

import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; //导入方法依赖的package包/类
protected RestTemplate getRestTemplate() {
	ObjectMapper mapper = new ObjectMapper();
	mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
	mapper.registerModule(new Jackson2HalModule());

	MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
	converter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON));
	converter.setObjectMapper(mapper);

	return new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
}
 
开发者ID:ewolff,项目名称:microservice-cloudfoundry,代码行数:12,代码来源:CatalogClient.java

示例3: ssoFilter

import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; //导入方法依赖的package包/类
@Bean
public Filter ssoFilter(ClientResources client, String path) {
    MappingJackson2HttpMessageConverter customJsonMessageConverter = new
            MappingJackson2HttpMessageConverter();
    customJsonMessageConverter.setSupportedMediaTypes(Arrays.asList(MediaType.TEXT_PLAIN));
    MyOAuth2ClientAuthenticationProcessingFilter filter = new MyOAuth2ClientAuthenticationProcessingFilter(path);
    filter.setAllowSessionCreation(true);
    MyOAuth2RestTemplate template = new MyOAuth2RestTemplate(client.getClient(), oauth2ClientContext);
    template.setMessageConverters(Arrays.asList(customJsonMessageConverter));
    filter.setRestTemplate(template);
    MyUserInfoTokenServices tokenServices = new MyUserInfoTokenServices(client.getResource().getUserInfoUri(),
            client.getClient().getClientId(),
            userService,
            userWechatService,
            userPrivilegeService,
            privilegeConfigService);
    tokenServices.setRestTemplate(template);
    filter.setTokenServices(tokenServices);
    return filter;
}
 
开发者ID:luotuo,项目名称:springboot-security-wechat,代码行数:21,代码来源:SecurityConfig.java

示例4: mappingJackson2HttpMessageConverter

import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; //导入方法依赖的package包/类
@Bean
public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
    MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
    jsonConverter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
    objectMapper.registerModule(new Jackson2HalModule());
    jsonConverter.setObjectMapper(objectMapper);
    return jsonConverter;
}
 
开发者ID:pawankumar8608,项目名称:spring-cloud-microservices-docker,代码行数:12,代码来源:Application.java

示例5: ExampleRestTemplateInheritingFromZg

import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; //导入方法依赖的package包/类
public ExampleRestTemplateInheritingFromZg() {
    super();
    //json reply should be application/json but we get a text/plain
    for (HttpMessageConverter<?> hmc : this.getMessageConverters()) {
        if (hmc.getClass().isAssignableFrom(MappingJackson2HttpMessageConverter.class)) {
            MappingJackson2HttpMessageConverter mjhc = (MappingJackson2HttpMessageConverter) hmc;
            List<MediaType> lmt = new ArrayList<>(mjhc.getSupportedMediaTypes());
            lmt.add(MediaType.TEXT_PLAIN);
            mjhc.setSupportedMediaTypes(lmt);
        }
    }
}
 
开发者ID:zg2pro,项目名称:spring-rest-basis-example,代码行数:13,代码来源:ExampleRestTemplateInheritingFromZg.java

示例6: jacksonMessageConverter

import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; //导入方法依赖的package包/类
@Bean
public MappingJackson2HttpMessageConverter jacksonMessageConverter() {
    MappingJackson2HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter();
    jacksonConverter.setSupportedMediaTypes(Arrays.asList(MediaType.valueOf("application/json")));
    jacksonConverter.setObjectMapper(jacksonObjectMapper());
    return jacksonConverter;
}
 
开发者ID:simplymequeeny,项目名称:dynamodb-client-web-gui,代码行数:8,代码来源:WebAppConfig.java

示例7: jsonConverter

import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; //导入方法依赖的package包/类
@Bean
public MappingJackson2HttpMessageConverter jsonConverter() {
	Jackson2ObjectMapperBuilder builder = Jackson2ObjectMapperBuilder.xml();
	builder.indentOutput(true);
	MappingJackson2HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter(builder.build());
	jacksonConverter.setSupportedMediaTypes(Arrays.asList(MediaType.valueOf("application/json")));
	jacksonConverter.setObjectMapper(jacksonObjectMapper());
	return jacksonConverter;
}
 
开发者ID:vadivelmurugesan,项目名称:spring-batch-admin,代码行数:10,代码来源:WebConfig.java

示例8: customConverters

import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; //导入方法依赖的package包/类
@Bean
public HttpMessageConverters customConverters() {
    MappingJackson2HttpMessageConverter jsonConverter =
            new MappingJackson2HttpMessageConverter();
    jsonConverter.setSupportedMediaTypes(Arrays.asList(
            new MediaType("application", "json"),
            new MediaType("text", "json")
    ));

    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new JsonOrgModule());
    jsonConverter.setObjectMapper(objectMapper);
    return new HttpMessageConverters(jsonConverter);
}
 
开发者ID:chaokunyang,项目名称:jkes,代码行数:15,代码来源:WebConfig.java

示例9: init

import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; //导入方法依赖的package包/类
@PostConstruct
public void init() {
  restTemplate = new RestTemplate();

  SimpleClientHttpRequestFactory rf = (SimpleClientHttpRequestFactory) restTemplate.getRequestFactory();
  rf.setReadTimeout(portalConfig.readTimeout());
  rf.setConnectTimeout(portalConfig.connectTimeout());

  MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
  converter.setSupportedMediaTypes(
      Arrays.asList(MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM));

  restTemplate.setMessageConverters(Arrays.asList(converter, new FormHttpMessageConverter()));

}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:16,代码来源:CtripMQService.java

示例10: getJacksonHttpMessageConverters

import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; //导入方法依赖的package包/类
@Bean
public HttpMessageConverters getJacksonHttpMessageConverters(ObjectMapper objectMapper) {
    MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(objectMapper);
    converter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON_UTF8, MediaType.TEXT_HTML, MediaType.TEXT_PLAIN));
    return new HttpMessageConverters(converter);
}
 
开发者ID:JThink,项目名称:SkyEye,代码行数:7,代码来源:MvcConfig.java


注:本文中的org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.setSupportedMediaTypes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。