潤乾報表分頁遇到的問題


環境:java+tomcat+struts2+spring+hibernate

邏輯:點擊查詢的時候,會訪問后台的一個方法getRunqianPara,返回潤乾文件名和參數params,跳轉到data-statistic-launch-runqian.jsp

問題:在頁面data-statistic-launch-runqian.jsp中能正常顯示潤乾報表,但是點擊"下一頁"的圖標按鈕的時候報錯,報錯頁面如下:

我的data-statistic-launch-runqian.jsp頁面代碼如下:

 1 <%@ page language="java" contentType="text/html; charset=UTF-8"
 2     pageEncoding="UTF-8"%>
 3 <%@ taglib uri="http://www.cnblogs.com/runqian/runqianReport4.tld" prefix="runqian" %>
 4 
 5 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 6     <%  
 7         String appmap = request.getContextPath();
 8         String firstPageImage = "<img src='"
 9                 + appmap
10                 + "/style1/images/firstpage.gif' border=no style='vertical-align:middle'>";
11         String lastPageImage = "<img src='"
12                 + appmap
13                 + "/style1/images/lastpage.gif' border=no style='vertical-align:middle'>";
14         String nextPageImage = "<img src='"
15                 + appmap
16                 + "/style1/images/nextpage.gif' border=no style='vertical-align:middle'>";
17         String prevPageImage = "<img src='"
18                 + appmap
19                 + "/style1/images/prevpage.gif' border=no style='vertical-align:middle'>";
20         String printImage = "<img src='"
21                 + appmap
22                 + "/style1/images/rq_print.gif' border=no style='vertical-align:middle'>";
23         String excelImage = "<img src='"
24                 + appmap
25                 + "/style1/images/excel.gif' border=no style='vertical-align:middle'>";
26         String pdfImage = "<img src='" + appmap
27                 + "/style1/images/pdf.gif' border=no style='vertical-align:middle'>";
28     %>
29 <runqian:html name="report" reportFileName="${modelName}"
30                         funcBarLocation="bottom" params="${params}" needPrint="yes"
31                         needScroll="no"
32                         needOfflineInput="yes" needSaveAsExcel="yes"
33                         needImportExcel="yes" needSaveAsPdf="yes" generateParamForm="no"
34                         exceptionPage="/index/reportError.ftl" needPageMark="yes"
35                         pageMarkLabel="頁號{currpage}/{totalPage}" displayNoLinkPageMark="yes" width="-1"
36                         firstPageLabel="<%=firstPageImage%>" 
37                         prevPageLabel="<%=prevPageImage%>" 
38                         nextPageLabel="<%=nextPageImage%>" 
39                         lastPageLabel="<%=lastPageImage%>" 
40                         printLabel="<%=printImage%>" 
41                         excelLabel="<%=excelImage%>" 
42                         pdfLabel="<%=pdfImage%>"/>

在網上找了一大圈,找到博主“薄荷紅茶”的這個文章http://starbhhc.iteye.com/blog/1544122,文章中前兩步,我都是這樣做的,第三步沒看懂。

后來這樣分析:

在data-statistic-launch-runqian.jsp頁面中,將鼠標放在下一頁的圖標上,IE的左下角會出現鏈接地址

這時發現和會訪問后台的鏈接是一樣的

通過IE的debug看,找到腳本,選擇對應的頁面

會看到這樣的代碼:

1 <script language=javascript>
2     function report_toPage( pageNo ) {
3     if( pageNo < 1 || pageNo > report_getTotalPage() ) return;
4         document.report_turnPageForm.report_currPage.value = pageNo;
5         document.report_turnPageForm.submit();
6     }
7 </script>

還有這個:

1 <form name="report_turnPageForm" method=post action="http://localhost:8080/omms-web/WEB-INF/content/transmission/data-statistic-launch-runqian.jsp?t_i_m_e=1347517433155" style="display:none">

這時候想到了博主“薄荷紅茶”的文章中說的內容的第三點了。

其實點擊“下一頁”按鈕圖標的時候,默認是對form的遞交,而form的action默認是data-statistic-launch-runqian.jsp頁面(也就是自身頁面)

如果你的params參數是在jsp頁面中拼接的,則不用修改action地址,如果是后台傳過來的,那么你需要修改action

 

解決方法:

用js修改form的action為訪問后台的地址,例如我這里是在data-statistic-launch-runqian.jsp頁面最后一行添加以下代碼:

<script type="text/javascript">
    document.report_turnPageForm.action="<%=request.getContextPath()%>/transmission/data-statistic-launch!getRunqianPara.action";
</script>

其實這一步就是博主“薄荷紅茶”的文章中說的內容的第三點

 

注意:

①如果你使用的是iframe,有時會因為緩存的原因沒看出頁面發生變化,最好采取清除緩存措施

②潤乾報表的raq文件是否有中文在這里沒有關系


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM