1.
web.xml
<servlet>
<servlet-name>FundPaymentServlet</servlet-name>
<servlet-class>com.dnion.dayu.jasper.FundPaymentServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FundPaymentServlet</servlet-name>
<url-pattern>/fundpayment</url-pattern>
</servlet-mapping>
2.
按钮触发时执行的代码:
String url = "/fundpayment";
Executions.getCurrent().sendRedirect(url, "_blank");
3.
FundPaymentServlet.java
public class FundPaymentServlet extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {
Rectangle rect = new Rectangle(800,600);
Document document = new Document(rect);
response.setContentType("application/pdf");
PdfWriter.getInstance(document, response.getOutputStream());
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
com.lowagie.text.Font FontChinese = new com.lowagie.text.Font(bfChinese, 8, com.lowagie.text.Font.NORMAL);
Modules module = new Modules(FontChinese);
HeaderFooter footer = new HeaderFooter(new Paragraph("表单编号:Dnion 4-114 版本1.0", FontChinese), false);
footer.setBorder(Rectangle.NO_BORDER);
footer.setAlignment(Element.ALIGN_RIGHT);
document.setFooter( footer);
document.open();
//标题栏
document.add(module.getTitle( request , term.getContract(),title,FontChinese,"客户信息"));