ireport打印问题

dever2011 dever2011 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我用jetty跑的项目,在我本地,想做个用ireport打印功能,用的是Jaspersoft iReport Designer 4.5.1
项目中用的也是这个Jar包,在点击打印按钮额时候,跳转到controller里,向request里set相关参数,然后跳转到打印页面,页面代码

<%@page language="java" contentType="text/html; charset=UTF-8"%>
<%@page import="java.net.URLEncoder"%>
<%@page import="java.net.URLDecoder"%>
<%@ include file="/common/taglibs.jsp"%>
<%
String params="",reportFile;
String caseNo =(String) request.getAttribute("caseNo");
String caseApplicant =(String) request.getAttribute("caseApplicant");
String caseType =(String) request.getAttribute("caseType");
String caseStartDateBegin =(String) request.getAttribute("caseStartDateBegin");
String caseStartDateEnd =(String) request.getAttribute("caseStartDateEnd");
String surplusDays = (String)request.getAttribute("surplusDays");
String caseEndDateBegin =(String) request.getAttribute("caseEndDateBegin");
String caseEndDateEnd =(String) request.getAttribute("caseEndDateEnd");
String caseStatus =(String) request.getAttribute("caseStatus");
String code =(String) request.getAttribute("code");
String chtype =(String) request.getAttribute("chtype");

reportFile ="/report/reportFiles/bangjiantongji.jasper";
params="method=printReport&reportFile="+reportFile+"&caseNo="+caseNo+"&caseApplicant="+URLEncoder.encode(caseApplicant,"utf-8")+"&caseType="+URLEncoder.encode(caseType,"utf-8")+"&caseStartDateBegin="+caseStartDateBegin
+"&caseStartDateEnd="+caseStartDateEnd+"&surplusDays="+surplusDays+"&caseEndDateBegin="+caseEndDateBegin+"&caseEndDateEnd="+caseEndDateEnd+"&caseStatus="+URLEncoder.encode(caseStatus,"utf-8")
+"&code="+URLEncoder.encode(code,"utf-8")+"&caseType="+URLEncoder.encode(chtype,"utf-8");
%>

<HTML>

<HEAD>

<TITLE></TITLE>

</HEAD>


<script lanuage="javascript">
<!--
function unLoadReportSession()
{
window.frm.action = "${ctx}/unloadSession/unloadSession.do?method=upload";
window.frm.submit();
}

function loadReport()
{
var sWidth=window.screen.width;
var sHeight=window.screen.height-30;
window.resizeTo(sWidth,sHeight);
window.moveTo(0,0);
}
//-->
</script>
<body onunload="unLoadReportSession();" onload="loadReport()"
leftmargin="0" topmargin="0" rightmargin="0">
<form id="frm" method="post">
</form>
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "100%" HEIGHT = "100%" codebase="${ctx }/j2re.exe#Version=5,0,0,5"><NOEMBED></NOEMBED>
<APPLET CODE = "EmbeddedViewerApplet.class" CODEBASE="${ctx }/applets" ARCHIVE = "jasperreports-applet-4.5.1.jar,commons-logging-1.1.1.jar,commons-collections-2.1.1.jar" WIDTH = "100%" HEIGHT = "100%"></XMP>
<PARAM NAME = CODE VALUE = "EmbeddedViewerApplet.class" >
<PARAM NAME = CODEBASE VALUE = "${ctx }/applets" >
<PARAM NAME = ARCHIVE VALUE = "jasperreports-applet-4.5.1.jar,commons-logging-1.1.1.jar,commons-collections-2.1.1.jar" >
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.5.0">
<PARAM NAME="scriptable" VALUE="false">
<PARAM NAME = "REPORT_URL" VALUE="${ctx }/jreport.do?<%=params%>">
</APPLET>

</body>
</HTML>
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
dever2011
Java EE 67,535 成员 225,843 内容