Java 配置@RequestMapping produces 参数 导出文件

日常开发中常用的produces 参数是:produces = {"application/json;charset=UTF-8"} 

如果要实现一些特殊的接口和需求,比如导出各种不同类型的文件,只需改变produces 参数即可。

注*:produces参数是一个数组,可以接受多个不同的参数类型,如下:

导出文件类型 produces 参数
'doc' application/msword;charset=UTF-8
'bin' application/octet-stream;charset=UTF-8
'exe' application/octet-stream;charset=UTF-8
'so' application/octet-stream;charset=UTF-8
'dll' application/octet-stream;charset=UTF-8
'pdf' application/pdf;charset=UTF-8
'ai' application/postscript;charset=UTF-8
'xls' application/vnd.ms-excel;charset=UTF-8
'ppt' application/vnd.ms-powerpoint;charset=UTF-8
'dir' application/x-director;charset=UTF-8
'js' application/x-javascript;charset=UTF-8
'swf' application/x-shockwave-flash;charset=UTF-8
'xhtml' application/xhtml+xml;charset=UTF-8
'xht' application/xhtml+xml;charset=UTF-8
'zip' application/zip;charset=UTF-8
'mid' audio/midi;charset=UTF-8
'midi' audio/midi;charset=UTF-8
'mp3' audio/mpeg;charset=UTF-8
'rm' audio/x-pn-realaudio;charset=UTF-8
'rpm' audio/x-pn-realaudio-plugin;charset=UTF-8
'wav' audio/x-wav;charset=UTF-8
'bmp' image/bmp;charset=UTF-8
'gif' image/gif;charset=UTF-8
'jpeg' image/jpeg;charset=UTF-8
'jpg' image/jpeg;charset=UTF-8
'png' image/png;charset=UTF-8
'css' text/css;charset=UTF-8
'html' text/html;charset=UTF-8
'htm' text/html;charset=UTF-8
'txt' text/plain;charset=UTF-8
'xsl' text/xml;charset=UTF-8
'xml' text/xml;charset=UTF-8
'mpeg' video/mpeg;charset=UTF-8
'mpg' video/mpeg;charset=UTF-8
'avi' video/x-msvideo;charset=UTF-8
'movie' video/x-sgi-movie',;charset=UTF-8

有问题联系我即可。

发布了67 篇原创文章 · 获赞 678 · 访问量 20万+

猜你喜欢

转载自blog.csdn.net/qq_26465035/article/details/103633250