web.xml: <servlet> <servlet-name>CdnContractServlet</servlet-name> <servlet-class>com.dnion.dayu.jasper.CdnContractServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>CdnContractServlet</servlet-name> <url-pattern>/cdncontract</url-pattern> </servlet-mapping> 调用方式: Session session = Sessions.getCurrent(); session.setAttribute("cdncontract_id", contract_id.getValue()); session.setAttribute("cdnflowname", flowname.getValue()); Executions.sendRedirect("/cdncontract"); 实现类: package com.dnion.dayu.jasper; import java.io.IOException; import java.util.List; import java.util.Map; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import com.dnion.dayu.exception.BusinessTypeException; import com.dnion.dayu.flowengine.BusinessJudgment; import com.dnion.dayu.log.BMCLogFactory; import com.dnion.dayu.log.LogCenter; import com.dnion.dayu.storage.dao.AltercontractDAO; import com.dnion.dayu.storage.dao.ContractDAO; import com.dnion.dayu.storage.dao.SalesreportDAO; import com.dnion.dayu.storage.dao.SpecialchargeDAO; import com.dnion.dayu.storage.entity.Altercontract; import com.dnion.dayu.storage.entity.Contract; import com.dnion.dayu.storage.entity.Salesreport; import com.dnion.dayu.storage.entity.Specialcharge; import com.dnion.dayu.storage.entity.User; import com.lowagie.text.Document; import com.lowagie.text.DocumentException; import com.lowagie.text.Element; import com.lowagie.text.HeaderFooter; import com.lowagie.text.PageSize; import com.lowagie.text.Paragraph; import com.lowagie.text.Rectangle; import com.lowagie.text.pdf.BaseFont; import com.lowagie.text.pdf.PdfWriter; public class CdnContractServlet extends HttpServlet { /** * Constructor of the object. */ public CdnContractServlet() { super(); } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); String id = request.getParameter("cdncontract_id"); Document document = new Document(PageSize.A4, 2, 3, 36, 36); if (null != id && id.trim().length() > 0) { try { 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); HeaderFooter footer = new HeaderFooter(new Paragraph("表单编号:Dnion 4-112 版本 1.0", FontChinese), false); footer.setBorder(Rectangle.NO_BORDER); footer.setAlignment(Element.ALIGN_RIGHT); document.setFooter(footer); document.open(); ContractDAO condao = new ContractDAO(); Contract contract = condao.findById(Integer.parseInt(id.toString())); Modules module = new Modules(); // 标题栏 document.add(module.getTitle(request, contract, "CDN业务合同审批表", FontChinese, "客户信息")); // 附件 document.add(module.getModelname("合同附件", FontChinese)); document.add(module.getAffix(document, FontChinese, contract)); // 流转意见 document.add(module.getModelname("流转意见", FontChinese)); String flowname = request.getParameter("cdnflowname"); User user = (User) request.getSession().getAttribute(User.class.getName()); if (flowname != null) { module.getflowinfo(document, FontChinese, flowname, user, map); } BMCLogFactory logfactory = (BMCLogFactory) LogCenter.getCenter().getFactory(BMCLogFactory.class.getName()); logfactory.recordprintLog(user, contract.getNumber() + "", request.getRemoteHost()); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } document.close(); } } }