2

我有一个 jsp 页面,我从中调用一个 Java 类。该类包含用于生成 pdf 的代码。

现在,当我单击按钮时,还会显示一个空的 jsp 以及 pdf。我希望当我单击按钮时该 jsp 页面不会打开。只应显示该 pdf。

这是我的 jsp 页面。我正在调用使用 Windchill API 的类

<%@page import="wt.part.WTPart"%>
<%@page import="wt.fc.WTObject"%>
<%@page import="ext.gt.checkOut.New"%>
<%
    String part2="GT024";
    ext.gt.checkOut.New.pdf1(part2);
%>
4

2 回答 2

1

从 Windchill 问答网站http://ezcollab.com/questions/93/how-to-stream-file-in-jsp获得

response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment;filename=\"" + fileName + "\"");       
BufferedOutputStream bufferedoutputstream = new BufferedOutputStream(response.getOutputStream());     
于 2013-03-18T03:00:03.177 回答
1

尝试添加
<%
response.setContentType("application/pdf");
response.setHeader("Content-disposition", "attachment; filename=yourfilename.pdf");
%>

于 2013-02-16T11:49:11.337 回答