vertx 给浏览器返回文件
ctx.response().putHeader("content-Type", "application/vnd.ms-excel");
//下面设置浏览器下载的文件名 包含文件后缀
ctx.response().putHeader("Content-Disposition", "attachment;filename="+"ordersxxxxx.xls");
ctx.response().sendFile(filename);
前端
//#dddc 任意可点击的东西 ,#daochu01 需要带给服务器的参数 $("#dddc").on('click', function () { var url = "http://" + window.location.host + "/ddgl/dddc"; $('<form method="get" action=' + url + '>' + '<input name="daochu01" type="text" value='+$("#daochu01").val()+'/>' + '<input name="daochu02" type="text" value='+$("#daochu02").val()+'/>' + '</form>').appendTo('body').submit().remove(); }); //ajax请求服务器,是不能返回excel表格的(这个不确定),我们需要把请求转换为页面请求,即转换为form表单发送请求,这样就可以把数据导出为表格了
浙公网安备 33010602011771号