public class FormHttpMessageWriter extends java.lang.Object implements HttpMessageWriter<MultiValueMap<java.lang.String,java.lang.String>>
HttpMessageWriter
to write HTML form data, i.e.
response body with media type "application/x-www-form-urlencoded"
.Modifier and Type | Field and Description |
---|---|
static java.nio.charset.Charset |
DEFAULT_CHARSET |
private java.nio.charset.Charset |
defaultCharset |
private static ResolvableType |
MULTIVALUE_TYPE |
Constructor and Description |
---|
FormHttpMessageWriter() |
Modifier and Type | Method and Description |
---|---|
boolean |
canWrite(ResolvableType elementType,
MediaType mediaType)
Indicates whether the given class can be written by this converter.
|
private java.lang.String |
generateForm(MultiValueMap<java.lang.String,java.lang.String> form,
java.nio.charset.Charset charset) |
java.nio.charset.Charset |
getDefaultCharset()
Return the configured default charset.
|
private java.nio.charset.Charset |
getMediaTypeCharset(MediaType mediaType) |
java.util.List<MediaType> |
getWritableMediaTypes()
Return the list of
MediaType objects that can be written by this converter. |
void |
setDefaultCharset(java.nio.charset.Charset charset)
Set the default character set to use for writing form data when the response
Content-Type header does not explicitly specify it.
|
<any> |
write(<any> inputStream,
ResolvableType elementType,
MediaType mediaType,
ReactiveHttpOutputMessage outputMessage,
java.util.Map<java.lang.String,java.lang.Object> hints)
Write an given object to the given output message.
|
public static final java.nio.charset.Charset DEFAULT_CHARSET
private static final ResolvableType MULTIVALUE_TYPE
private java.nio.charset.Charset defaultCharset
public void setDefaultCharset(java.nio.charset.Charset charset)
By default this is set to "UTF-8".
public java.nio.charset.Charset getDefaultCharset()
public boolean canWrite(ResolvableType elementType, MediaType mediaType)
HttpMessageWriter
canWrite
in interface HttpMessageWriter<MultiValueMap<java.lang.String,java.lang.String>>
elementType
- the stream element type to test for writabilitymediaType
- the media type to write, can be null
if not specified.
Typically the value of an Accept
header.true
if writable; false
otherwisepublic <any> write(<any> inputStream, ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage outputMessage, java.util.Map<java.lang.String,java.lang.Object> hints)
HttpMessageWriter
write
in interface HttpMessageWriter<MultiValueMap<java.lang.String,java.lang.String>>
inputStream
- the input stream to writeelementType
- the stream element type to process. This type must have previously
been passed to the HttpMessageWriter.canWrite(org.springframework.core.ResolvableType, org.springframework.http.MediaType)
canWrite} method of this interface, which must
have returned true
.mediaType
- the content type to use when writing, typically the value of an
Accept
header. May be null
to indicate that the default content
type of the converter must be used.outputMessage
- the message to write tohints
- additional information about how to writeMono
that indicates completion or errorprivate java.nio.charset.Charset getMediaTypeCharset(MediaType mediaType)
private java.lang.String generateForm(MultiValueMap<java.lang.String,java.lang.String> form, java.nio.charset.Charset charset)
public java.util.List<MediaType> getWritableMediaTypes()
HttpMessageWriter
MediaType
objects that can be written by this converter.getWritableMediaTypes
in interface HttpMessageWriter<MultiValueMap<java.lang.String,java.lang.String>>