类 FormHttpMessageWriter
java.lang.Object
cn.taketoday.http.codec.LoggingCodecSupport
cn.taketoday.http.codec.FormHttpMessageWriter
- 所有已实现的接口:
HttpMessageWriter<cn.taketoday.util.MultiValueMap<String,String>>
public class FormHttpMessageWriter
extends LoggingCodecSupport
implements HttpMessageWriter<cn.taketoday.util.MultiValueMap<String,String>>
HttpMessageWriter for writing a MultiValueMap<String, String>
as HTML form data, i.e. "application/x-www-form-urlencoded", to the
body of a request.
Note that unless the media type is explicitly set to
MediaType.APPLICATION_FORM_URLENCODED, the canWrite(cn.taketoday.core.ResolvableType, cn.taketoday.http.MediaType) method
will need generic type information to confirm the target map has String values.
This is because a MultiValueMap with non-String values can be used to write
multipart requests.
To support both form data and multipart requests, consider using
MultipartHttpMessageWriter
configured with this writer as the fallback for writing plain form data.
- 从以下版本开始:
- 4.0
- 作者:
- Sebastien Deleuze, Rossen Stoyanchev
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明static final CharsetThe default charset used by the writer.private static final MediaTypeprivate Charsetprivate static final cn.taketoday.core.ResolvableType从类继承的字段 cn.taketoday.http.codec.LoggingCodecSupport
logger -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明booleanWhether the given object type is supported by this writer.Return the configured default charset.protected MediaTypegetMediaType(MediaType mediaType) Return the list of media types supported by this Writer.private voidprotected StringserializeForm(cn.taketoday.util.MultiValueMap<String, String> formData, Charset charset) voidsetDefaultCharset(Charset charset) Set the default character set to use for writing form data when the response Content-Type header does not explicitly specify it.reactor.core.publisher.Mono<Void>write(org.reactivestreams.Publisher<? extends cn.taketoday.util.MultiValueMap<String, String>> inputStream, cn.taketoday.core.ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage message, Map<String, Object> hints) Write an given stream of object to the output message.从类继承的方法 cn.taketoday.http.codec.LoggingCodecSupport
isEnableLoggingRequestDetails, setEnableLoggingRequestDetails从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.http.codec.HttpMessageWriter
getWritableMediaTypes, write
-
字段详细资料
-
DEFAULT_CHARSET
The default charset used by the writer. -
DEFAULT_FORM_DATA_MEDIA_TYPE
-
MEDIA_TYPES
-
MULTIVALUE_TYPE
private static final cn.taketoday.core.ResolvableType MULTIVALUE_TYPE -
defaultCharset
-
-
构造器详细资料
-
FormHttpMessageWriter
public FormHttpMessageWriter()
-
-
方法详细资料
-
setDefaultCharset
Set the default character set to use for writing form data when the response Content-Type header does not explicitly specify it.By default this is set to "UTF-8".
-
getDefaultCharset
Return the configured default charset. -
getWritableMediaTypes
从接口复制的说明:HttpMessageWriterReturn the list of media types supported by this Writer. The list may not apply to every possible target element type and calls to this method should typically be guarded viacanWrite(elementType, null). The list may also exclude media types supported only for a specific element type. Alternatively, useHttpMessageWriter.getWritableMediaTypes(ResolvableType)for a more precise list.- 指定者:
getWritableMediaTypes在接口中HttpMessageWriter<cn.taketoday.util.MultiValueMap<String,String>> - 返回:
- the general list of supported media types
-
canWrite
public boolean canWrite(cn.taketoday.core.ResolvableType elementType, @Nullable MediaType mediaType) 从接口复制的说明:HttpMessageWriterWhether the given object type is supported by this writer.- 指定者:
canWrite在接口中HttpMessageWriter<cn.taketoday.util.MultiValueMap<String,String>> - 参数:
elementType- the type of object to checkmediaType- the media type for the write (possiblynull)- 返回:
trueif writable,falseotherwise
-
write
public reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<? extends cn.taketoday.util.MultiValueMap<String, String>> inputStream, cn.taketoday.core.ResolvableType elementType, @Nullable MediaType mediaType, ReactiveHttpOutputMessage message, Map<String, Object> hints) 从接口复制的说明:HttpMessageWriterWrite an given stream of object to the output message.- 指定者:
write在接口中HttpMessageWriter<cn.taketoday.util.MultiValueMap<String,String>> - 参数:
inputStream- the objects to writeelementType- the type of objects in the stream which must have been previously checked viaHttpMessageWriter.canWrite(ResolvableType, MediaType)mediaType- the content type for the write (possiblynullto indicate that the default content type of the writer must be used)message- the message to write tohints- additional information about how to encode and write- 返回:
- indicates completion or error
-
getMediaType
-
logFormData
-
serializeForm
-