日期:2014-05-17  浏览次数:20543 次

setContentType(MIME) 出错
我在servlet的doGet()中加入:
response.setContentType(MIME);
报错: MIME没有找到。
我该怎么办?

------解决方案--------------------
MIME是变量名吧。你是不是没定义??代码网上下的??
------解决方案--------------------
http://www.w3school.com.cn/media/media_mimeref.asp
text/plain(纯文本)
text/html(HTML文档)
application/xhtml+xml(XHTML文档)
image/gif(GIF图像)
image/jpeg(JPEG图像)
image/png(PNG图像)
------解决方案--------------------
contentType="text/html;charset=GBK"
------解决方案--------------------

res.setContentType("text/html");
// 指定 HTTP 响应的输出的文档MIME类型,默认为text/html
// 常用的MIME类型还有image/gif(GIF图片)
//                  image/bitmap(BMP图象)
//                  text/plain(文本文档TXT)
//                  text/vnd.wap.wml(手机WAP页面)
//                  application/vnd.ms-excel(excel表格)
// 同时可以指定了浏览器显示的编码, 如res.setContentType("text/html;charset=utf-8")