本文整理匯總了Java中org.springframework.http.converter.AbstractHttpMessageConverter類的典型用法代碼示例。如果您正苦於以下問題:Java AbstractHttpMessageConverter類的具體用法?Java AbstractHttpMessageConverter怎麽用?Java AbstractHttpMessageConverter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AbstractHttpMessageConverter類屬於org.springframework.http.converter包,在下文中一共展示了AbstractHttpMessageConverter類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: withSpecificJsonMessageConverter
import org.springframework.http.converter.AbstractHttpMessageConverter; //導入依賴的package包/類
public RestTemplateBuilder withSpecificJsonMessageConverter() {
isUseDefaultJsonMessageConverter = false;
AbstractHttpMessageConverter<?> jsonMessageConverter = new MappingJackson2HttpMessageConverter(
Jackson2ObjectMapperBuilder
.json()
.featuresToEnable(
DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY,
DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)
.build());
jsonMessageConverter.setSupportedMediaTypes(Lists.newArrayList(
MediaType.TEXT_HTML, MediaType.TEXT_PLAIN,
MediaType.APPLICATION_JSON));
withMessageConverter(jsonMessageConverter);
return this;
}
示例2: writeInternal
import org.springframework.http.converter.AbstractHttpMessageConverter; //導入依賴的package包/類
private void writeInternal(Object object, HttpOutputMessage outputMessage) throws Exception {
Method method = AbstractHttpMessageConverter.class.getDeclaredMethod(
"writeInternal", Object.class, HttpOutputMessage.class);
method.setAccessible(true);
method.invoke(this.converter, object, outputMessage);
}
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:7,代碼來源:MappingJackson2XmlHttpMessageConverterTests.java