本文整理汇总了Java中javax.servlet.http.HttpServletResponse.getContentType方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServletResponse.getContentType方法的具体用法?Java HttpServletResponse.getContentType怎么用?Java HttpServletResponse.getContentType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.servlet.http.HttpServletResponse
的用法示例。
在下文中一共展示了HttpServletResponse.getContentType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendFallback
import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
private void sendFallback(Integer size, HttpServletResponse response) throws IOException {
if (response.getContentType() == null) {
response.setContentType(StringUtil.getMimeType("jpeg"));
}
InputStream in = null;
try {
in = getClass().getResourceAsStream("default_cover.jpg");
BufferedImage image = ImageIO.read(in);
if (size != null) {
image = scale(image, size, size);
}
ImageIO.write(image, "jpeg", response.getOutputStream());
} finally {
IOUtils.closeQuietly(in);
}
}
示例2: putHeaders
import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
public static void putHeaders(HttpServletResponse response, HttpContent content, long contentLength, boolean etag)
{
long lml=content.getResource().lastModified();
if (lml>=0)
response.setDateHeader(HttpHeader.LAST_MODIFIED.asString(),lml);
if (contentLength==0)
contentLength=content.getContentLengthValue();
if (contentLength >=0)
{
if (contentLength<Integer.MAX_VALUE)
response.setContentLength((int)contentLength);
else
response.setHeader(HttpHeader.CONTENT_LENGTH.asString(),Long.toString(contentLength));
}
String ct=content.getContentTypeValue();
if (ct!=null && response.getContentType()==null)
response.setContentType(ct);
String ce=content.getContentEncodingValue();
if (ce!=null)
response.setHeader(HttpHeader.CONTENT_ENCODING.asString(),ce);
if (etag)
{
String et=content.getETagValue();
if (et!=null)
response.setHeader(HttpHeader.ETAG.asString(),et);
}
}
示例3: isBinaryContent
import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
private boolean isBinaryContent(final HttpServletResponse response) {
return response.getContentType() != null && (response.getContentType()
.startsWith("image") || response.getContentType().startsWith("video") || response
.getContentType().startsWith("audio"));
}
示例4: isMultipart
import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
private boolean isMultipart(final HttpServletResponse response) {
return response.getContentType() != null && (response.getContentType()
.startsWith("multipart/form-data") || response.getContentType()
.startsWith("application/octet-stream"));
}