HttpMessageConverter that can read and write strings.
By default, this converter supports all media types (*/*),
and writes with a Content-Type of text/plain. This can be overridden
by setting the supportedMediaTypes property.
| Modifier and Type | Field and Description |
|---|---|
| private static final MediaType | |
| private volatile List | |
| public static final Charset | DEFAULT_CHARSET
The default charset used by the converter. |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public | StringHttpMessageConverter(Charset defaultCharset)
A constructor accepting a default charset to use if the requested content type does not specify one. |
| Modifier and Type | Method and Description |
|---|---|
| protected void | addDefaultHeaders(HttpHeaders headers, String s, MediaType type)
Overrides org. Add default headers to the output message. |
| protected List | |
| protected Long | getContentLength(String
the type to return the content length for str, MediaType contentType)Overrides org. Returns the content length for the given type. |
| private Charset | |
| protected String | readInternal(Class<? extends String>
the type of object to return clazz, HttpInputMessage the HTTP input message to read from inputMessage)Implements abstract org. Abstract template method that reads the actual object. |
| public void | setWriteAcceptCharset(boolean writeAcceptCharset)
Whether the |
| public boolean | supports(Class<?>
the class to test for support clazz)Implements abstract org. Indicates whether the given class is supported by this converter. |
| protected boolean | supportsRepeatableWrites(String
the object t s)Overrides org. Indicates whether this message converter can write the given object multiple times. |
| protected void | writeInternal(String
the object to write to the output message str, HttpOutputMessage the HTTP output message to write to outputMessage)Implements abstract org. Abstract template method that writes the actual body. |
| APPLICATION_PLUS_JSON | back to summary |
|---|---|
| private static final MediaType APPLICATION_PLUS_JSON | |
| availableCharsets | back to summary |
|---|---|
| private volatile List<Charset> availableCharsets
| |
| DEFAULT_CHARSET | back to summary |
|---|---|
| public static final Charset DEFAULT_CHARSET The default charset used by the converter. | |
| writeAcceptCharset | back to summary |
|---|---|
| private boolean writeAcceptCharset | |
| StringHttpMessageConverter | back to summary |
|---|---|
| public StringHttpMessageConverter() A default constructor that uses
| |
| StringHttpMessageConverter | back to summary |
|---|---|
| public StringHttpMessageConverter(Charset defaultCharset) A constructor accepting a default charset to use if the requested content type does not specify one. | |
| addDefaultHeaders | back to summary |
|---|---|
| protected void addDefaultHeaders(HttpHeaders headers, String s, MediaType type) throws IOException Overrides org. Doc from org. Add default headers to the output message. This implementation delegates to
| |
| getAcceptedCharsets | back to summary |
|---|---|
| protected List Return the list of supported By default, returns | |
| getContentLength | back to summary |
|---|---|
| protected Long getContentLength(String str, MediaType contentType) Overrides org. Doc from org. Returns the content length for the given type. By default, this returns | |
| getContentTypeCharset | back to summary |
|---|---|
| private Charset getContentTypeCharset(MediaType contentType) | |
| readInternal | back to summary |
|---|---|
| protected String readInternal(Class<? extends String> clazz, HttpInputMessage inputMessage) throws IOException Implements abstract org. Doc from org. Abstract template method that reads the actual object. Invoked from
| |
| setWriteAcceptCharset | back to summary |
|---|---|
| public void setWriteAcceptCharset(boolean writeAcceptCharset) Whether the As of 5.2, by default is set to | |
| supports | back to summary |
|---|---|
| public boolean supports(Class<?> clazz) Implements abstract org. Doc from org. Indicates whether the given class is supported by this converter. | |
| supportsRepeatableWrites | back to summary |
|---|---|
| protected boolean supportsRepeatableWrites(String s) Overrides org. Doc from org. Indicates whether this message converter can write the given object multiple times. Default implementation returns | |
| writeInternal | back to summary |
|---|---|
| protected void writeInternal(String str, HttpOutputMessage outputMessage) throws IOException Implements abstract org. Doc from org. Abstract template method that writes the actual body. Invoked from
| |