public enum ContentType extends Enum<ContentType>
Enum Constant and Description |
---|
EVENT_STREAM
text/event-stream编码
|
FORM_URLENCODED
标准表单编码,当action为get时候,浏览器用x-www-form-urlencoded的编码方式把form数据转换成一个字串(name1=value1&name2=value2…)
|
JSON
Rest请求JSON编码
|
MULTIPART
文件上传编码,浏览器会把整个表单以控件为单位分割,并为每个部分加上Content-Disposition,并加上分割符(boundary)
|
OCTET_STREAM
application/octet-stream编码
|
TEXT_HTML
text/html编码
|
TEXT_PLAIN
text/plain编码
|
TEXT_XML
Rest请求text/xml编码
|
XML
Rest请求XML编码
|
Modifier and Type | Method and Description |
---|---|
static String |
build(ContentType contentType,
Charset charset)
输出Content-Type字符串,附带编码信息
|
static String |
build(String contentType,
Charset charset)
输出Content-Type字符串,附带编码信息
|
static ContentType |
get(String body)
从请求参数的body中判断请求的Content-Type类型,支持的类型有:
1. application/json
1. application/xml
|
String |
getValue()
获取value值
|
static boolean |
isDefault(String contentType)
是否为默认Content-Type,默认包括
null 和application/x-www-form-urlencoded |
static boolean |
isFormUrlEncode(String contentType)
是否为application/x-www-form-urlencoded
|
String |
toString() |
String |
toString(Charset charset)
输出Content-Type字符串,附带编码信息
|
static ContentType |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static ContentType[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ContentType FORM_URLENCODED
public static final ContentType MULTIPART
public static final ContentType JSON
public static final ContentType XML
public static final ContentType TEXT_PLAIN
public static final ContentType TEXT_XML
public static final ContentType TEXT_HTML
public static final ContentType OCTET_STREAM
public static final ContentType EVENT_STREAM
public static ContentType[] values()
for (ContentType c : ContentType.values()) System.out.println(c);
public static ContentType valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic String getValue()
public String toString()
toString
in class Enum<ContentType>
public String toString(Charset charset)
charset
- 编码public static boolean isDefault(String contentType)
null
和application/x-www-form-urlencodedcontentType
- 内容类型public static boolean isFormUrlEncode(String contentType)
contentType
- 内容类型public static ContentType get(String body)
1. application/json 1. application/xml
body
- 请求参数体public static String build(String contentType, Charset charset)
contentType
- Content-Type类型charset
- 编码public static String build(ContentType contentType, Charset charset)
contentType
- Content-Type 枚举类型charset
- 编码Copyright © 2024. All rights reserved.