本文整理汇总了Java中org.springframework.util.MimeTypeUtils.APPLICATION_JSON属性的典型用法代码示例。如果您正苦于以下问题:Java MimeTypeUtils.APPLICATION_JSON属性的具体用法?Java MimeTypeUtils.APPLICATION_JSON怎么用?Java MimeTypeUtils.APPLICATION_JSON使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.util.MimeTypeUtils
的用法示例。
在下文中一共展示了MimeTypeUtils.APPLICATION_JSON属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mimeTypeFromObject
/**
* Convert payload to {@link MimeType} based on the content type on the message.
*
* @param payload the payload to convert
* @param originalContentType content type on the message
* @return converted {@link MimeType}
*/
public static MimeType mimeTypeFromObject(Object payload, String originalContentType) {
Assert.notNull(payload, "payload object cannot be null.");
if (payload instanceof byte[]) {
return MimeTypeUtils.APPLICATION_OCTET_STREAM;
}
if (payload instanceof String) {
return MimeTypeUtils.APPLICATION_JSON_VALUE.equals(originalContentType) ? MimeTypeUtils.APPLICATION_JSON
: MimeTypeUtils.TEXT_PLAIN;
}
String className = payload.getClass().getName();
MimeType mimeType = mimeTypesCache.get(className);
if (mimeType == null) {
String modifiedClassName = className;
if (payload.getClass().isArray()) {
// Need to remove trailing ';' for an object array, e.g.
// "[Ljava.lang.String;" or multi-dimensional
// "[[[Ljava.lang.String;"
if (modifiedClassName.endsWith(";")) {
modifiedClassName = modifiedClassName.substring(0, modifiedClassName.length() - 1);
}
// Wrap in quotes to handle the illegal '[' character
modifiedClassName = "\"" + modifiedClassName + "\"";
}
mimeType = MimeType.valueOf("application/x-java-object;type=" + modifiedClassName);
mimeTypesCache.put(className, mimeType);
}
return mimeType;
}
示例2: BusJacksonMessageConverter
public BusJacksonMessageConverter(ObjectMapper objectMapper) {
super(MimeTypeUtils.APPLICATION_JSON);
if (objectMapper != null) {
this.mapper = objectMapper;
} else {
this.mapper = new ObjectMapper();
}
}
示例3: JacksonConverter
public JacksonConverter() {
super(MimeTypeUtils.APPLICATION_JSON);
}