ireport插入圖片

ireport插入圖片


1. 在模板上拖一個image組件,設置它的image Expression爲變量$P{logo},如圖示,屬性下面的is lazy勾上。

   不然有可能最後頁面渲染出來的image的src爲nullimage_0_0_0。


2. 給變量logo的值。  

    String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+"/"+request.getContextPath(); 
    parameterMap.put("logo",basePath + "/sf_home/resources/logo1.jpg");
   // 填充模板數據
   jp = JasperFillManager.fillJasperReport(jr, parameterMap, dataSource);
   // 緩存報表
   session.setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jp);


參考文檔:http://my.oschina.net/x2space/blog/74375
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章