HttpServletResponse对象
HttpServletResponse对象代表服务器的响应。这个对象中封装了响应客户端浏览器的流对象,以及向客户端浏览器响应的响应头、响应数据、响应状态码等信息。
设置响应类型
resp.setContentType(“MIME”)
该方法可通过MIME-Type设置响应类型。
Type | Meaning |
---|---|
application/msword | Microsoft Word document |
application/octet-stream | Unrecognized or binary data |
application/pdf | Acrobat (.pdf) file |
application/postscript | PostScript file |
application/vnd.lotus-notes | Lotus Notes file |
application/vnd.ms-excel | Excel spreadsheet |
application/vnd.ms-powerpoint | PowerPoint presentation |
application/x-gzip | Gzip archive |
application/x-java-archive | JAR file |
application/x-java-serialized-object | Serialized Java object |
application/x-java-vm | Java bytecode (.class) file |
application/zip | Zip archive |
application/json | JSON |
audio/basic | Sound file in .au or .snd format |
audio/midi | MIDI sound file |
audio/x-aiff | AIFF sound file |
audio/x-wav | Microsoft Windows sound file |
image/gif | GIF image |
image/jpeg | JPEG image |
image/png | PNG image |
image/tiff | TIFF image |
image/x-xbitmap | X Windows bitmap image |
text/css | HTML cascading style sheet |
text/html | HTML document |
text/plain | Plain text |
text/xml | XML |
video/mpeg | MPEG video clip |
video/quicktime | QuickTime video clip |