使用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));
}});以上給出了錯誤:您的瀏覽器發送了此服務器無法理解的請求。
使用Ajax下載并打開PDF文件
莫回無
2019-08-16 16:59:26