我有一个调用 servlet 的 jsp,它可以“即时”创建一个 pdf。
public class HelloWorld extends Action
{
public static final String RESULT= "C:\hello.pdf";
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
{
try {
new HelloWorld().createPdf(RESULT);
} catch (Exception e) {
e.printStackTrace();
return mapping.findForward("Failure");
}
return mapping.findForward("Success");
}
public void createPdf(String filename) throws IOException, DocumentException {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(filename));
document.open();
PdfPTable table = createTable1();
document.add(table);
document.close();
}
public static PdfPTable createTable1() throws DocumentException {
...
}
}
我想要一个像“另存为”这样的消息框,而不是静态路径C:\hello.pdf