为了账号安全,请及时绑定邮箱和手机立即绑定

使用Ajax下载并打开PDF文件

使用Ajax下载并打开PDF文件

莫回无 2019-08-16 16:59:26
使用Ajax下载并打开PDF文件我有一个生成PDF的动作类。该contentType适当地设定。public class MyAction extends ActionSupport {    public String execute() {     ...     ...     File report = signedPdfExporter.generateReport(xyzData, props);     inputStream = new FileInputStream(report);     contentDisposition = "attachment=\"" + report.getName() + "\"";     contentType = "application/pdf";     return SUCCESS;    }}我action 通过Ajax调用来调用它。我不知道将此流传递给浏览器的方法。我尝试过一些东西,但没有任何效果。$.ajax({     type: "POST",     url: url,     data: wireIdList,     cache: false,     success: function(response)     {         alert('got response');         window.open(response);     },     error: function (XMLHttpRequest, textStatus, errorThrown)      {         alert('Error occurred while opening fax template'                + getAjaxErrorString(textStatus, errorThrown));     }});以上给出了错误:您的浏览器发送了此服务器无法理解的请求。
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 1688 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信