本文整理汇总了Java中org.springframework.http.converter.json.MappingJacksonHttpMessageConverter类的典型用法代码示例。如果您正苦于以下问题:Java MappingJacksonHttpMessageConverter类的具体用法?Java MappingJacksonHttpMessageConverter怎么用?Java MappingJacksonHttpMessageConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MappingJacksonHttpMessageConverter类属于org.springframework.http.converter.json包,在下文中一共展示了MappingJacksonHttpMessageConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDefaultHttpMessageConverters
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter; //导入依赖的package包/类
/**
* Adds a set of default HttpMessageConverter instances to the given list.
* Subclasses can call this method from {@link #configureMessageConverters(List)}.
* @param messageConverters the list to add the default message converters to
*/
protected final void addDefaultHttpMessageConverters(List<HttpMessageConverter<?>> messageConverters) {
StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
stringConverter.setWriteAcceptCharset(false);
messageConverters.add(new ByteArrayHttpMessageConverter());
messageConverters.add(stringConverter);
messageConverters.add(new ResourceHttpMessageConverter());
messageConverters.add(new SourceHttpMessageConverter<Source>());
messageConverters.add(new AllEncompassingFormHttpMessageConverter());
if (romePresent) {
messageConverters.add(new AtomFeedHttpMessageConverter());
messageConverters.add(new RssChannelHttpMessageConverter());
}
if (jaxb2Present) {
messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
}
if (jackson2Present) {
messageConverters.add(new MappingJackson2HttpMessageConverter());
}
else if (jacksonPresent) {
messageConverters.add(new MappingJacksonHttpMessageConverter());
}
}
示例2: setup
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter; //导入依赖的package包/类
@Before
public void setup() {
this.people = new LinkedMultiValueMap<String, Person>();
this.people.add("composers", new Person("Johann Sebastian Bach"));
this.people.add("composers", new Person("Johannes Brahms"));
this.people.add("composers", new Person("Edvard Grieg"));
this.people.add("composers", new Person("Robert Schumann"));
this.people.add("performers", new Person("Vladimir Ashkenazy"));
this.people.add("performers", new Person("Yehudi Menuhin"));
List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
converters.add(new MappingJacksonHttpMessageConverter());
this.restTemplate = new RestTemplate();
this.restTemplate.setMessageConverters(converters);
this.mockServer = MockRestServiceServer.createServer(this.restTemplate);
}
示例3: getTagsFor
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter; //导入依赖的package包/类
private SpotlightAnnotation getTagsFor(URI fragment,String text) throws TransformException {
RestTemplate rest = new RestTemplate();
CommonsClientHttpRequestFactory clientHttpRequestFactory = new CommonsClientHttpRequestFactory();
clientHttpRequestFactory.setReadTimeout(10000);
rest.setRequestFactory(clientHttpRequestFactory);
List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
converters.add(new MappingJacksonHttpMessageConverter());
converters.add(new FormHttpMessageConverter());
rest.setMessageConverters(converters);
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
map.add("prefix", fragment.toString()+"#");
map.add("text", text.toString());
HttpEntity<?> httpEntity = new HttpEntity<Object>(map, getHttpHeaders());
try {
SpotlightAnnotation annotation = rest.postForObject(config.getSpotlightUrl(), httpEntity, SpotlightAnnotation.class);
annotation.setFragmentURI(fragment);
return annotation;
}
catch (RestClientException e) {
log.warn("could not request tags for: " + text);
log.warn(e.getMessage());
return new SpotlightAnnotation();
}
}
示例4: init
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter; //导入依赖的package包/类
public static void init(List<HttpMessageConverter<?>> messageConverters) {
messageConverters.add(new ByteArrayHttpMessageConverter());
messageConverters.add(new StringHttpMessageConverter());
messageConverters.add(new ResourceHttpMessageConverter());
// if javax.xml.transform is not available, fall back to standard Form message converter
if (javaxXmlTransformPresent) {
messageConverters.add(new SourceHttpMessageConverter<Source>());
messageConverters.add(new XmlAwareFormHttpMessageConverter());
} else {
messageConverters.add(new FormHttpMessageConverter());
}
if (simpleXmlPresent) {
messageConverters.add(new SimpleXmlHttpMessageConverter());
}
if (jackson2Present) {
messageConverters.add(new MappingJackson2HttpMessageConverter());
} else if (jacksonPresent) {
messageConverters.add(new MappingJacksonHttpMessageConverter());
}
if (romePresent) {
messageConverters.add(new SyndFeedHttpMessageConverter());
}
}
示例5: configureMessageConverters
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter; //导入依赖的package包/类
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(new StringHttpMessageConverter());
converters.add(new Jaxb2RootElementHttpMessageConverter());
converters.add(new MappingJacksonHttpMessageConverter());
converters.add(new ReportCsvMessageConverter());
}
示例6: setup
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter; //导入依赖的package包/类
@Before
public void setup() {
List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
converters.add(new StringHttpMessageConverter());
converters.add(new MappingJacksonHttpMessageConverter());
this.restTemplate = new RestTemplate();
this.restTemplate.setMessageConverters(converters);
this.mockServer = MockRestServiceServer.createServer(this.restTemplate);
}
示例7: getMessageConverters
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter; //导入依赖的package包/类
private ManagedList<?> getMessageConverters(Element element, Object source, ParserContext parserContext) {
Element convertersElement = DomUtils.getChildElementByTagName(element, "message-converters");
ManagedList<? super Object> messageConverters = new ManagedList<Object>();
if (convertersElement != null) {
messageConverters.setSource(source);
for (Element beanElement : DomUtils.getChildElementsByTagName(convertersElement, "bean", "ref")) {
Object object = parserContext.getDelegate().parsePropertySubElement(beanElement, null);
messageConverters.add(object);
}
}
if (convertersElement == null || Boolean.valueOf(convertersElement.getAttribute("register-defaults"))) {
messageConverters.setSource(source);
messageConverters.add(createConverterDefinition(ByteArrayHttpMessageConverter.class, source));
RootBeanDefinition stringConverterDef = createConverterDefinition(StringHttpMessageConverter.class, source);
stringConverterDef.getPropertyValues().add("writeAcceptCharset", false);
messageConverters.add(stringConverterDef);
messageConverters.add(createConverterDefinition(ResourceHttpMessageConverter.class, source));
messageConverters.add(createConverterDefinition(SourceHttpMessageConverter.class, source));
messageConverters.add(createConverterDefinition(AllEncompassingFormHttpMessageConverter.class, source));
if (romePresent) {
messageConverters.add(createConverterDefinition(AtomFeedHttpMessageConverter.class, source));
messageConverters.add(createConverterDefinition(RssChannelHttpMessageConverter.class, source));
}
if (jaxb2Present) {
messageConverters.add(createConverterDefinition(Jaxb2RootElementHttpMessageConverter.class, source));
}
if (jackson2Present) {
messageConverters.add(createConverterDefinition(MappingJackson2HttpMessageConverter.class, source));
}
else if (jacksonPresent) {
messageConverters.add(createConverterDefinition(MappingJacksonHttpMessageConverter.class, source));
}
}
return messageConverters;
}
示例8: setUp
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter; //导入依赖的package包/类
@Before
public void setUp() {
AllEncompassingFormHttpMessageConverter converter = new AllEncompassingFormHttpMessageConverter();
converter.setPartConverters(Arrays.<HttpMessageConverter<?>>asList(
new ResourceHttpMessageConverter(), new MappingJacksonHttpMessageConverter()));
restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory());
restTemplate.setMessageConverters(Arrays.<HttpMessageConverter<?>>asList(converter));
}
示例9: RestTemplate
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter; //导入依赖的package包/类
/**
* Create a new instance of the {@link RestTemplate} using default settings.
* Default {@link HttpMessageConverter}s are initialized.
*/
public RestTemplate() {
this.messageConverters.add(new ByteArrayHttpMessageConverter());
this.messageConverters.add(new StringHttpMessageConverter());
this.messageConverters.add(new ResourceHttpMessageConverter());
this.messageConverters.add(new SourceHttpMessageConverter<Source>());
this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());
if (romePresent) {
this.messageConverters.add(new AtomFeedHttpMessageConverter());
this.messageConverters.add(new RssChannelHttpMessageConverter());
}
if (jaxb2Present) {
this.messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
}
if (jackson2Present) {
this.messageConverters.add(new MappingJackson2HttpMessageConverter());
}
else if (jacksonPresent) {
this.messageConverters.add(new MappingJacksonHttpMessageConverter());
}
}
示例10: AllEncompassingFormHttpMessageConverter
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter; //导入依赖的package包/类
public AllEncompassingFormHttpMessageConverter() {
addPartConverter(new SourceHttpMessageConverter());
if (jaxb2Present) {
addPartConverter(new Jaxb2RootElementHttpMessageConverter());
}
if (jackson2Present) {
addPartConverter(new MappingJackson2HttpMessageConverter());
}
else if (jacksonPresent) {
addPartConverter(new MappingJacksonHttpMessageConverter());
}
}
示例11: getHttpMessageConverters
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter; //导入依赖的package包/类
private List<HttpMessageConverter<?>> getHttpMessageConverters() {
List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
messageConverters.add(new ByteArrayHttpMessageConverter());
messageConverters.add(new StringHttpMessageConverter());
messageConverters.add(new ResourceHttpMessageConverter());
messageConverters.add(new UploadApplicationPayloadHttpMessageConverter());
messageConverters.add(getFormHttpMessageConverter());
messageConverters.add(new MappingJacksonHttpMessageConverter());
return messageConverters;
}
示例12: initTemplate
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter; //导入依赖的package包/类
public static RestTemplate initTemplate() {
RestTemplate template = new RestTemplate();
List<HttpMessageConverter<?>> convertors = template
.getMessageConverters();
MappingJacksonHttpMessageConverter converter = new MappingJacksonHttpMessageConverter();
List<MediaType> mediaTypes = new ArrayList<MediaType>();
mediaTypes.add(new MediaType("application", "json"));
converter.setSupportedMediaTypes(mediaTypes);
convertors.add(converter);
template.setMessageConverters(convertors);
return template;
}
示例13: mappingJacksonHttpMessageConverter
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public MappingJacksonHttpMessageConverter mappingJacksonHttpMessageConverter(
ObjectMapper objectMapper) {
MappingJacksonHttpMessageConverter converter = new MappingJacksonHttpMessageConverter();
converter.setObjectMapper(objectMapper);
return converter;
}
示例14: facebookRestTemplate
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter; //导入依赖的package包/类
@Bean
@Scope(value = "session", proxyMode = ScopedProxyMode.INTERFACES)
public OAuth2RestTemplate facebookRestTemplate() {
OAuth2RestTemplate template = new OAuth2RestTemplate(facebook(), new DefaultOAuth2ClientContext(
accessTokenRequest));
MappingJacksonHttpMessageConverter converter = new MappingJacksonHttpMessageConverter();
converter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON,
MediaType.valueOf("text/javascript")));
template.setMessageConverters(Arrays.<HttpMessageConverter<?>> asList(converter));
return template;
}
示例15: setUp
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter; //导入依赖的package包/类
@Before
public void setUp() {
request = new MockHttpServletRequest();
request.setAttribute(HandlerMapping.INTROSPECT_TYPE_LEVEL_MAPPING, true);
request.setRequestURI("/ajax/listAllPagified");
request.setMethod("GET");
response = new MockHttpServletResponse();
adapter = new AnnotationMethodHandlerAdapter();
MappingJacksonHttpMessageConverter messageConverter = new MappingJacksonHttpMessageConverter();
adapter.setMessageConverters(new HttpMessageConverter[] { messageConverter });
ajaxController = new AjaxController();
ajaxController.setAccountService(accountService);
}