有關(guān)spring(或其他框架)結(jié)合ec導(dǎo)出xls,pdf的問題(原創(chuàng))
Posted on 2006-12-02 15:38 碼農(nóng)cz 閱讀(247) 評(píng)論(0) 編輯 收藏
? ec將取得的數(shù)據(jù)存入request中。但是ec的標(biāo)簽ec:table 中的action屬性一般都是定位到當(dāng)前的jsp。再從當(dāng)前的request中取數(shù)據(jù)。如果,action只是定位到自己。ok,導(dǎo)出的xls或pdf只有列名,沒有數(shù)值。
? 解決辦法:
??????? 1.在頁面的頭中添加
?
? 解決辦法:
??????? 1.在頁面的頭中添加
?
?1?<%
?2???Object?obj=request.getAttribute("persons");
?3???if(obj!=null){
?4????session.setAttribute("persons",(List)obj);
?5???}else{
?6????List?list=(List)session.getAttribute("persons");
?7????request.setAttribute("persons",list);
?8???}
?9???List?list?=?(List)?request.getAttribute("persons");
10???//System.out.println(list.getClass().getName());
11???session.setAttribute("persons",?list);
12?%>
?2???Object?obj=request.getAttribute("persons");
?3???if(obj!=null){
?4????session.setAttribute("persons",(List)obj);
?5???}else{
?6????List?list=(List)session.getAttribute("persons");
?7????request.setAttribute("persons",list);
?8???}
?9???List?list?=?(List)?request.getAttribute("persons");
10???//System.out.println(list.getClass().getName());
11???session.setAttribute("persons",?list);
12?%>
? 較為簡(jiǎn)單,不說了。方法很齷齪。
? 2.
??? AppTemplate.wc?action=showAttributes
??? 將ec:table 的屬性action定位到查詢數(shù)據(jù)的servlet name。就是讓它再查一次。
?? 魚與熊掌不可兼得啊!
ok了 ,enjoy it!