Package org.springframework.http.converter

Examples of org.springframework.http.converter.FormHttpMessageConverter


   * By default, the message converter is set to use "UTF-8" character encoding.
   * Override to customize the message converter (for example, to set supported media types or message converters for the parts of a multipart message).
   * To remove/replace this or any of the other message converters that are registered by default, override the getMessageConverters() method instead.
   */
  protected FormHttpMessageConverter getFormMessageConverter() {
    FormHttpMessageConverter converter = new FormHttpMessageConverter();
    converter.setCharset(Charset.forName("UTF-8"));
    List<HttpMessageConverter<?>> partConverters = new ArrayList<HttpMessageConverter<?>>();
    partConverters.add(new ByteArrayHttpMessageConverter());
    StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(Charset.forName("UTF-8"));
    stringHttpMessageConverter.setWriteAcceptCharset(false);
    partConverters.add(stringHttpMessageConverter);
    partConverters.add(new ResourceHttpMessageConverter());   
    converter.setPartConverters(partConverters);
    return converter;
  }
View Full Code Here


   */
  protected RestTemplate createRestTemplate() {
    ClientHttpRequestFactory requestFactory = ClientHttpRequestFactorySelector.getRequestFactory();
    RestTemplate restTemplate = new RestTemplate(requestFactory);
    List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>(2);
    converters.add(new FormHttpMessageConverter());
    converters.add(new FormMapHttpMessageConverter());
    converters.add(new MappingJackson2HttpMessageConverter());
    restTemplate.setMessageConverters(converters);
    if (!useParametersForClientAuthentication) {
      List<ClientHttpRequestInterceptor> interceptors = restTemplate.getInterceptors();
View Full Code Here

   * By default, the message converter is set to use "UTF-8" character encoding.
   * Override to customize the message converter (for example, to set supported media types or message converters for the parts of a multipart message).
   * To remove/replace this or any of the other message converters that are registered by default, override the getMessageConverters() method instead.
   */
  protected FormHttpMessageConverter getFormMessageConverter() {
    FormHttpMessageConverter converter = new FormHttpMessageConverter();
    converter.setCharset(Charset.forName("UTF-8"));
    List<HttpMessageConverter<?>> partConverters = new ArrayList<HttpMessageConverter<?>>();
    partConverters.add(new ByteArrayHttpMessageConverter());
    StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(Charset.forName("UTF-8"));
    stringHttpMessageConverter.setWriteAcceptCharset(false);
    partConverters.add(stringHttpMessageConverter);
    partConverters.add(new ResourceHttpMessageConverter());   
    converter.setPartConverters(partConverters);
    return converter;
  }
View Full Code Here

  // internal helpers

  private RestTemplate createRestTemplate() {
    RestTemplate restTemplate = new RestTemplate(ClientHttpRequestFactorySelector.getRequestFactory());
    List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>(1);
    converters.add(new FormHttpMessageConverter() {
      public boolean canRead(Class<?> clazz, MediaType mediaType) {
        // always read MultiValueMaps as x-www-url-formencoded even if contentType not set properly by provider       
        return MultiValueMap.class.isAssignableFrom(clazz);
      }
    });
View Full Code Here

public class FormMapHttpMessageConverter implements HttpMessageConverter<Map<String, String>> {

  private final FormHttpMessageConverter delegate;
 
  public FormMapHttpMessageConverter() {
    delegate = new FormHttpMessageConverter();
  }
View Full Code Here

  }

  @Override
  protected RestTemplate createRestTemplate() {
    RestTemplate restTemplate = new RestTemplate(ClientHttpRequestFactorySelector.getRequestFactory());
    FormHttpMessageConverter messageConverter = new FormHttpMessageConverter() {
      public boolean canRead(Class<?> clazz, MediaType mediaType) {
        // always read as x-www-url-formencoded even though Facebook sets contentType to text/plain       
        return true;
      }
    };
View Full Code Here

TOP

Related Classes of org.springframework.http.converter.FormHttpMessageConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.