当前位置: 首页>>代码示例>>Java>>正文


Java MimeType类代码示例

本文整理汇总了Java中com.feilong.io.entity.MimeType的典型用法代码示例。如果您正苦于以下问题:Java MimeType类的具体用法?Java MimeType怎么用?Java MimeType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MimeType类属于com.feilong.io.entity包,在下文中一共展示了MimeType类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolverContentType

import com.feilong.io.entity.MimeType; //导入依赖的package包/类
/**
 * Resolver content type.
 *
 * @param saveFileName
 *            the save file name
 * @param inputContentType
 *            the content type
 * @return the string
 * @since 1.4.0
 */
private static String resolverContentType(String saveFileName,String inputContentType){
    //See tomcat web.xml
    //When serving static resources, Tomcat will automatically generate a "Content-Type" header based on the resource's filename extension, based on these mappings.  
    //Additional mappings can be added here (to apply to all web applications), or in your own application's web.xml deployment descriptor.                                               -->

    if (isNotNullOrEmpty(inputContentType)){
        return inputContentType;
    }
    String contentTypeByFileName = MimeTypeUtil.getContentTypeByFileName(saveFileName);

    //contentType = "application/force-download";//,php强制下载application/force-download,将发送HTTP 标头您的浏览器并告诉它下载,而不是在浏览器中运行的文件
    //application/x-download

    //.*( 二进制流,不知道下载文件类型)   application/octet-stream
    return isNotNullOrEmpty(contentTypeByFileName) ? contentTypeByFileName : MimeType.BIN.getMime();
    //The HTTP specification recommends setting the Content-Type to application/octet-stream. 
    //Unfortunately, this causes problems with Opera 6 on Windows (which will display the raw bytes for any file whose extension it doesn't recognize) and on Internet Explorer 5.1 on the Mac (which will display inline content that would be downloaded if sent with an unrecognized type).
}
 
开发者ID:venusdrogon,项目名称:feilong-servlet,代码行数:29,代码来源:ResponseDownloadUtil.java

示例2: writeText

import com.feilong.io.entity.MimeType; //导入依赖的package包/类
/**
 * 以text的方式输出.
 *
 * @param response
 *            HttpServletResponse
 * @param text
 *            json字符串
 * @param characterEncoding
 *            the character encoding
 * @see #write(HttpServletResponse, Object, String, String)
 * @see com.feilong.io.entity.MimeType#TXT
 * @since 1.10.6
 */
public static void writeText(HttpServletResponse response,Object text,String characterEncoding){
    String contentType = MimeType.TXT.getMime() + ";charset=" + characterEncoding;
    write(response, text, contentType, characterEncoding);
}
 
开发者ID:venusdrogon,项目名称:feilong-servlet,代码行数:18,代码来源:ResponseUtil.java

示例3: writeJson

import com.feilong.io.entity.MimeType; //导入依赖的package包/类
/**
 * 以json的方式输出.
 *
 * @param response
 *            HttpServletResponse
 * @param json
 *            json字符串
 * @param characterEncoding
 *            the character encoding
 * @see #write(HttpServletResponse, Object, String, String)
 * @see com.feilong.io.entity.MimeType#JSON
 * @since 1.0.9
 */
public static void writeJson(HttpServletResponse response,Object json,String characterEncoding){
    String contentType = MimeType.JSON.getMime() + ";charset=" + characterEncoding;
    write(response, json, contentType, characterEncoding);
}
 
开发者ID:venusdrogon,项目名称:feilong-servlet,代码行数:18,代码来源:ResponseUtil.java


注:本文中的com.feilong.io.entity.MimeType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。