下面列出了org.springframework.http.MediaType#TEXT_XML 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private MediaType getContentType(String contentType) {
if (contentType.equalsIgnoreCase(MediaType.IMAGE_GIF_VALUE)) {
return MediaType.IMAGE_GIF;
} else if (contentType.equalsIgnoreCase(MediaType.IMAGE_PNG_VALUE)) {
return MediaType.IMAGE_PNG;
} else if (contentType.equalsIgnoreCase(MediaType.IMAGE_JPEG_VALUE)) {
return MediaType.IMAGE_JPEG;
} else if (contentType.equalsIgnoreCase(MediaType.TEXT_PLAIN_VALUE)) {
return MediaType.TEXT_PLAIN;
} else if (contentType.equalsIgnoreCase(MediaType.TEXT_XML_VALUE)) {
return MediaType.TEXT_XML;
} else if (contentType.equalsIgnoreCase(MediaType.TEXT_HTML_VALUE)) {
return MediaType.TEXT_HTML;
}
return MediaType.APPLICATION_OCTET_STREAM;
}
private MediaType getContentType(String contentType) {
if (contentType.equalsIgnoreCase(MediaType.IMAGE_GIF_VALUE)) {
return MediaType.IMAGE_GIF;
} else if (contentType.equalsIgnoreCase(MediaType.IMAGE_PNG_VALUE)) {
return MediaType.IMAGE_PNG;
} else if (contentType.equalsIgnoreCase(MediaType.IMAGE_JPEG_VALUE)) {
return MediaType.IMAGE_JPEG;
} else if (contentType.equalsIgnoreCase(MediaType.TEXT_PLAIN_VALUE)) {
return MediaType.TEXT_PLAIN;
} else if (contentType.equalsIgnoreCase(MediaType.TEXT_XML_VALUE)) {
return MediaType.TEXT_XML;
} else if (contentType.equalsIgnoreCase(MediaType.TEXT_HTML_VALUE)) {
return MediaType.TEXT_HTML;
}
return MediaType.APPLICATION_OCTET_STREAM;
}
/**
* Protected constructor that sets the {@link #setSupportedMediaTypes(java.util.List) supportedMediaTypes}
* to {@code text/xml} and {@code application/xml}, and {@code application/*-xml}.
*/
protected AbstractXmlHttpMessageConverter() {
super(MediaType.APPLICATION_XML, MediaType.TEXT_XML, new MediaType("application", "*+xml"));
}
/**
* Sets the {@link #setSupportedMediaTypes(java.util.List) supportedMediaTypes}
* to {@code text/xml} and {@code application/xml}, and {@code application/*-xml}.
*/
public SourceHttpMessageConverter() {
super(MediaType.APPLICATION_XML, MediaType.TEXT_XML, new MediaType("application", "*+xml"));
}
/**
* Protected constructor that sets the {@link #setSupportedMediaTypes(java.util.List) supportedMediaTypes}
* to {@code text/xml} and {@code application/xml}, and {@code application/*-xml}.
*/
protected AbstractXmlHttpMessageConverter() {
super(MediaType.APPLICATION_XML, MediaType.TEXT_XML, new MediaType("application", "*+xml"));
}
/**
* Sets the {@link #setSupportedMediaTypes(java.util.List) supportedMediaTypes}
* to {@code text/xml} and {@code application/xml}, and {@code application/*-xml}.
*/
public SourceHttpMessageConverter() {
super(MediaType.APPLICATION_XML, MediaType.TEXT_XML, new MediaType("application", "*+xml"));
}
/**
* Protected constructor that sets the {@link #setSupportedMediaTypes(java.util.List) supportedMediaTypes}
* to {@code text/xml} and {@code application/xml}, and {@code application/*-xml}.
*/
protected AbstractXmlHttpMessageConverter() {
super(MediaType.APPLICATION_XML, MediaType.TEXT_XML, new MediaType("application", "*+xml"));
}
/**
* Sets the {@link #setSupportedMediaTypes(java.util.List) supportedMediaTypes}
* to {@code text/xml} and {@code application/xml}, and {@code application/*-xml}.
*/
public SourceHttpMessageConverter() {
super(MediaType.APPLICATION_XML, MediaType.TEXT_XML, new MediaType("application", "*+xml"));
}
/**
* Protected constructor that sets the {@link #setSupportedMediaTypes(java.util.List) supportedMediaTypes}
* to {@code text/xml} and {@code application/xml}, and {@code application/*-xml}.
*/
protected AbstractXmlHttpMessageConverter() {
super(MediaType.APPLICATION_XML, MediaType.TEXT_XML, new MediaType("application", "*+xml"));
}
/**
* Sets the {@link #setSupportedMediaTypes(java.util.List) supportedMediaTypes}
* to {@code text/xml} and {@code application/xml}, and {@code application/*-xml}.
*/
public SourceHttpMessageConverter() {
super(MediaType.APPLICATION_XML, MediaType.TEXT_XML, new MediaType("application", "*+xml"));
}