**
post方式
**
var postDownLoadFile = function (options) {
var config = $.extend(true, {method: 'post'}, options);
var $iframe = $('<iframe id="down-file-iframe" />');
var $form = $('<form target="down-file-iframe" method="' + config.method + '" />');
$form.attr('action', config.url);
for (var key in config.data) {
$form.append('<input type="hidden" name="' + key + '" value="' + config.data[key] + '" />');
}
$iframe.append($form);
$(document.body).append($iframe);
$form[0].submit();
$iframe.remove();
}
function ex() {
postDownLoadFile({
url: "/excel/download",
data:
method: "POST",
dataType: "JSON",
responseType: 'blob',
success:function (data) {
}
})
get方式
window.location.href = "/excel/download"+"?"+"&year="+year;
参考文章:https://blog.csdn.net/andyliulin/article/details/78122870