Example usage for org.springframework.http.converter FormHttpMessageConverter setCharset

List of usage examples for org.springframework.http.converter FormHttpMessageConverter setCharset

Introduction

In this page you can find the example usage for org.springframework.http.converter FormHttpMessageConverter setCharset.

Prototype

public void setCharset(@Nullable Charset charset) 

Source Link

Document

Set the default character set to use for reading and writing form data when the request or response Content-Type header does not explicitly specify it.

Usage

From source file:org.intermine.app.service.RoboSpiceService.java

@Override
public RestTemplate createRestTemplate() {
    RestTemplate rtp = new RestTemplate();
    Charset utf8 = Charset.forName(CHARSET);

    ByteArrayHttpMessageConverter byteConv = new ByteArrayHttpMessageConverter();
    StringHttpMessageConverter stringConv = new StringHttpMessageConverter(utf8);

    FormHttpMessageConverter formConv = new FormHttpMessageConverter();
    formConv.setCharset(utf8);

    List<HttpMessageConverter<?>> converters = rtp.getMessageConverters();

    converters.add(byteConv);/*from   w w w  .j av a2  s.c  o  m*/
    converters.add(stringConv);
    converters.add(formConv);

    rtp.setMessageConverters(converters);
    return rtp;
}

From source file:org.openschedule.api.impl.AbstractOpenSchedulApiBinding.java

/**
 * Returns an {@link FormHttpMessageConverter} to be used by the internal {@link RestTemplate}.
 * 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.
 *///from www .  ja  v a 2  s . c om
protected FormHttpMessageConverter getFormMessageConverter() {
    FormHttpMessageConverter converter = new FormHttpMessageConverter();
    converter.setCharset(Charset.forName("UTF-8"));
    return converter;
}