我做了一个小程序,使用jcom在web上实现打印预览的功能。使用MyEclipse运行正常,但发布到tomcat之后就卡住了。
代码如下 public ActionForward tostamp(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
logger.info("tostamp getDownload method start");
ReleaseManager rm = new ReleaseManager();
condition = new HashMap();//初始化HASHMAP
downloadtabledataForm = (DownloadTableDataForm)form;//取得FROM
menuFlg = Utility.nullToString(request.getParameter("menuFlg"));//取得数据来源
try {
// 取得项目路径
String path = servlet.getServletContext().getRealPath(File.separator);
String tos1 = Utility.nullToString(request.getParameter("tos1")); String tos2 = Utility.nullToString(request.getParameter("tos2")); String tos3 = Utility.nullToString(request.getParameter("tos3")); String tos4 = Utility.nullToString(request.getParameter("tos4")); String tos5 = Utility.nullToString(request.getParameter("tos5"));
Map maps = new HashMap();
maps.clear();
maps.put("tos1", tos1);
maps.put("tos2", tos2);
maps.put("tos3", tos3);
maps.put("tos4", tos4);
maps.put("tos5", tos5);
String fileUrl = path + File.separator + CommConst.fileMYDownload + File.separator
+ CommConst.fileMYSubDownload + File.separator + "moban.xls";
this.setxls(fileUrl, maps);
logger.info("tostamp getDownload method 1");
ExcelApplication excel = new ExcelApplication(rm);
logger.info("tostamp getDownload method 2");
ExcelWorkbooks xlBooks = excel.Workbooks();
logger.info("tostamp getDownload method 3");
ExcelWorkbook xlBook = xlBooks.Open(fileUrl);
logger.info("tostamp getDownload method 4");
ExcelWorksheet xlSheet = excel.ActiveSheet();
logger.info("tostamp getDownload method 5"); excel.Visible(true);
logger.info("tostamp getDownload method 6");
xlSheet.PrintOut(1,1,1,true);
logger.info("tostamp getDownload method 7");
xlBook.Close(false, null, false);
logger.info("tostamp getDownload method 8");
excel.Quit();
}catch (Exception e) {//抛异常
e.printStackTrace();
request.setAttribute("messageFlg", "ERR");
return mapping.findForward("research");
}finally{
condition = null;
downloadtabledataForm = null;
menuFlg = null;
rm.release();
}
logger.info("tostamp getDownload method end");
return null;
}
打log跟踪显示是在“xlSheet.PrintOut(1,1,1,true);”处卡住了,请高手解决
代码如下 public ActionForward tostamp(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
logger.info("tostamp getDownload method start");
ReleaseManager rm = new ReleaseManager();
condition = new HashMap();//初始化HASHMAP
downloadtabledataForm = (DownloadTableDataForm)form;//取得FROM
menuFlg = Utility.nullToString(request.getParameter("menuFlg"));//取得数据来源
try {
// 取得项目路径
String path = servlet.getServletContext().getRealPath(File.separator);
String tos1 = Utility.nullToString(request.getParameter("tos1")); String tos2 = Utility.nullToString(request.getParameter("tos2")); String tos3 = Utility.nullToString(request.getParameter("tos3")); String tos4 = Utility.nullToString(request.getParameter("tos4")); String tos5 = Utility.nullToString(request.getParameter("tos5"));
Map maps = new HashMap();
maps.clear();
maps.put("tos1", tos1);
maps.put("tos2", tos2);
maps.put("tos3", tos3);
maps.put("tos4", tos4);
maps.put("tos5", tos5);
String fileUrl = path + File.separator + CommConst.fileMYDownload + File.separator
+ CommConst.fileMYSubDownload + File.separator + "moban.xls";
this.setxls(fileUrl, maps);
logger.info("tostamp getDownload method 1");
ExcelApplication excel = new ExcelApplication(rm);
logger.info("tostamp getDownload method 2");
ExcelWorkbooks xlBooks = excel.Workbooks();
logger.info("tostamp getDownload method 3");
ExcelWorkbook xlBook = xlBooks.Open(fileUrl);
logger.info("tostamp getDownload method 4");
ExcelWorksheet xlSheet = excel.ActiveSheet();
logger.info("tostamp getDownload method 5"); excel.Visible(true);
logger.info("tostamp getDownload method 6");
xlSheet.PrintOut(1,1,1,true);
logger.info("tostamp getDownload method 7");
xlBook.Close(false, null, false);
logger.info("tostamp getDownload method 8");
excel.Quit();
}catch (Exception e) {//抛异常
e.printStackTrace();
request.setAttribute("messageFlg", "ERR");
return mapping.findForward("research");
}finally{
condition = null;
downloadtabledataForm = null;
menuFlg = null;
rm.release();
}
logger.info("tostamp getDownload method end");
return null;
}
打log跟踪显示是在“xlSheet.PrintOut(1,1,1,true);”处卡住了,请高手解决
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货