使用windows.open("XXX.do");输出一个pdf文件 如何设置输出页面的title?
try {
String _url = WebUtils.getRealPath(request.getServletContext(), "/upload/temp/" + FileUtils.newFileName("1.pdf")); // 文件地址
this.createCollectFeePdf(collectFeeId, _url);
ServletOutputStream out = response.getOutputStream();
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "inline; filename=test.pdf");
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File(_url)));
BufferedOutputStream bos = new BufferedOutputStream(out);
byte[] buff = new byte[2048];
int len;
while ((len = bis.read(buff)) != -1) {
out.write(buff, 0, len);
out.flush();
}
bis.close();
bos.close();
} catch (Exception e) {
e.printStackTrace();
}
------解决思路----------------------
var aa = window.open('/servlet/xx');
var aa.document.write("<title>标题1</title>");
试试。。
------解决思路----------------------
如果在父窗口就已经知道子窗口的标题是什么,就可以这样写啊:
var myWindow = window.open("xxx.do");
myWindow.document.title="这里写个标题";
我以为楼主是要动态读取服务端PDF文件名作为标题呢。