Java下载程序中获取MIME类型大全(三)

2014-11-24 09:04:40 · 作者: · 浏览: 7
h.put("vrml","x-world/x-vrml");
h.put("wav","audio/x-wav");
h.put("wcm","application/vnd.ms-works");
h.put("wdb","application/vnd.ms-works");
h.put("wks","application/vnd.ms-works");
h.put("wmf","application/x-msmetafile");
h.put("wps","application/vnd.ms-works");
h.put("wri","application/x-mswrite");
h.put("wrl","x-world/x-vrml");
h.put("wrz","x-world/x-vrml");
h.put("xaf","x-world/x-vrml");
h.put("xbm","image/x-xbitmap");
h.put("xla","application/vnd.ms-excel");
h.put("xlc","application/vnd.ms-excel");
h.put("xlm","application/vnd.ms-excel");
h.put("xls","application/vnd.ms-excel");
h.put("xlt","application/vnd.ms-excel");
h.put("xlw","application/vnd.ms-excel");
h.put("xof","x-world/x-vrml");
h.put("xpm","image/x-xpixmap");
h.put("xwd","image/x-xwindowdump");
h.put("z","application/x-compress");
h.put("zip","application/zip");
mime = h.get(docType);
if(mime==null){
mime = "application/octet-stream";
}
return mime;
}


最后这样设置即可
response.setContentType(mine+"; charset=gb2312");
response.setHeader("Content-disposition", (new StringBuilder()).append("attachment;filename=\"").append(new String(name.getBytes("GBK"), "ISO8859_1")).append("\"").toString());