當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。