springboot ajax下载文件功能封装

 通过js ajax下载文件功能封装 

function exportExcel(formId, url) {
    try {
        var queryForm = $("#" + formId);
        var exportForm = $("
") queryForm.find("input").each(function() { var name = $(this).attr("name"); var value = $(this).val(); exportForm.append("") }); queryForm.find("select").each(function() { var name = $(this).attr("name"); var value = $(this).val(); exportForm.append("") }); $(document.body).append(exportForm); exportForm.submit(); } catch (e) { console.log(e); } finally { exportForm.remove(); } }

 

你可能感兴趣的:(js,java)