2 qq 36918049 qq_36918049 于 2017.09.05 11:29 提问

导出excel表单,extjs用ajax写没反应,请问用from提交怎么写

图片说明

1个回答

privateobject
privateobject   2017.09.06 09:54
已采纳

使用location.href,后台输出文件流

 HttpServletResponse.setContentType("text/html;charset=GBK");
        HttpServletResponse.setCharacterEncoding("GBK");
        OutputStream os = HttpServletResponse.getOutputStream();// 取得输出流
        HttpServletResponse.reset();// 清空输出流
        HttpServletResponse.setHeader("Content-disposition",
                "attachment; filename=" + new String(fileName.getBytes("GB2312"), "ISO8859-1") + ".xls");
        // 设定输出文件头
        HttpServletResponse.setContentType("application/msexcel");// 定义输出类型

privateobject
privateobject location.href=请求路径url
3 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片