Java 要从DWR请求打开PDF文件吗
我想从DWR调用打开一个pdf文件。我正在使用DWR2.0Java 要从DWR请求打开PDF文件吗,java,dwr,Java,Dwr,我想从DWR调用打开一个pdf文件。我正在使用DWR2.0 请引导我 我无法理解你所说的打开pdf文件是什么意思。根据我对您问题的理解,您可以使用DWR从服务器端到客户端获取pdf文件。然后,您必须使用任何客户端技术来显示它 在DWR网站中,您可以找到DWR.war文件。它包含一个下载pdf文件的示例。您已将该文件放在任何servlet容器的web apps文件夹中。然后您可以通过http://localhost:8080/dwr/考虑升级到DWR 3 在DWR3中,您将发现一个FileTran
请引导我 我无法理解你所说的
打开pdf文件
是什么意思。根据我对您问题的理解,您可以使用DWR从服务器端到客户端获取pdf文件。然后,您必须使用任何客户端技术来显示它
在DWR网站中,您可以找到DWR.war文件。它包含一个下载pdf文件的示例。您已将该文件放在任何servlet容器的web apps文件夹中。然后您可以通过
http://localhost:8080/dwr/
考虑升级到DWR 3
在DWR3中,您将发现一个FileTransfer对象
HTML:
爪哇:
<form action="downloadFile.do">
<div id="buttons">
<input type="button" value="Back" id="mapback" onClick="javascript:back();" class="Back" />
<input type="button" value="SavePDF" id="SavePDF" onclick="return downloadPdfFile();" class="saveToPdfButton" />
<input type="submit" value="Continue" id="continue" class="continue" />
</div>
</form>
function downloadPdfFile() {
dwr.engine.setTimeout(59000);
var callMetaData = {
callback : downloadPdfCallback,
exceptionHandler : hideLoadingAndSwitchOnSavePDFButton,
errorHandler : hideLoadingAndSwitchOnSavePDFButton,
preHook : showLoading,
postHook : hideLoading
};
DWRAction.downloadPdfFile(callMetaData);
return false;
}
function downloadPdfCallback(data) {
dwr.engine.openInDownload(data);
}
File pdfFile = new File(pdfFilename);
try {
InputStream is = new BufferedInputStream(new FileInputStream(pdfFile));
dwrPdfFile = new FileTransfer(pdfFile.getName(), "application/pdf", is);
} catch (FileNotFoundException e) {
LOGGER.error("Unable to find PDF file \'{}\'", pdfFile.getAbsoluteFile());
}