自从注册CSDN没写过一篇文章,今天闲来没事,整理点小东西,写下来。
birt从session中取从JSP传递的参数。
1、把JSP页面获得的参数放到session中,以下是简短代码:
<body>
<table>
<input type="text" id="name" />
<input type="text" id="age"/>
<input type="text" id="sex"/>
<input type="button" οnclick="subAajax()" />
</table>
<iframe name="reportIframe" id="reportIframe" height="82%"
style="width: 100%;z-index:9999;background: url(../images/public/8.gif);"frameborder="0" scrolling="auto" οnlοad="change();">
</iframe>
</body>
<script type="text/javascript">
function subAajax(){
var name=document.getElementById("name");
var age=document.getElementById("age");
var sex=document.getElementById("sex");
var reportIframe = document.getElementById("reportIframe");
var url1="<%= request.getContextPath()%>" + "/frameset?__report=/report/"+reportName+"&__toolbar=false";
var con="&name="+name+"&age="+age+"&sex="+sex;
$.ajax({
url:"<%= request.getContextPath()%>" +"/processRptdesign.do?method=addPosearchParam"+con, //处理页面
type:"post",
dataType:"html",
success:function(msg){
$("#reportIframe").attr("src",encodeURI(url1));
}
});
}
</script>
public class ProcessParamAction extends DispatchAction { public ActionForward addPosearchParam(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Map<String, String> map=new HashMap<String, String>(); String name=request.getParameter("name"); String age=request.getParameter("age"); String sex=request.getParameter("sex"); map.put("stime",stime); map.put("name",name); map.put("age",age); map.put("sex",sex); request.getSession().setAttribute( "AppContextKey","numberWhere"); request.getSession().setAttribute("AppContextValue", map); return null; }
2、在报表中取session中的数据,在before open中写如下代码获取:var name=numberWhere.get("name"); var age=numberWhere.get("age"); var sex=numberWhere.get("sex");
以上仅供参考,欢迎大家指正,共同学习