Moe*_*Moe 2 struts2 jasper-reports
我正在使用struts2 jasperreports插件,它运行良好.问题是我想传递exportParameters,我不知道如何通过插件来做到这一点.
您从哪个版本开始使用Struts2 2.1.2+提供了提供的功能exportParameters
您只需在操作类中的struts配置文件中添加以下条目或类似条目即可
<action name="myJasperTest" class="com.acme.test.action.JasperAction">
<result name="success" type="jasper">
<param name="location">foo.jasper</param>
<param name="dataSource">mySource</param>
<param name="exportParameters ">exportParameters </param>
</result>
</action>
Run Code Online (Sandbox Code Playgroud)
exportParameters - OGNL expression used to retrieve a map of JR exporter parameters from the value stack.导出参数用于自定义JR导出.例如,PDF导出可能启用加密并将用户密码设置为报表创建者已知的字符串.您只需要在操作类中为导出参数定义一个映射,并提供其getter/setter,而不是如上所述使用其引用.
有关详细信息,请参阅此URL
**Update**
Run Code Online (Sandbox Code Playgroud)
以下是他们如何在结果类型中完成它
exporter = new JRXlsExporter();
Map exportParams = (Map) stack.findValue(exportParameters);
if (exportParams != null) {
LOG.debug("Found export parameters; adding to exporter parameters...");
exporter.getParameters().putAll(exportParams);
}
Run Code Online (Sandbox Code Playgroud)
所以他们所做的是他们试图找到一个map带有名称的值堆栈,exportParameters如果他们发现它们正在添加它.所以必须在你的动作类中做到这一点
Map<String,String> exportParameters= //init your map here
Run Code Online (Sandbox Code Playgroud)
在此映射中设置属性,并为此属性创建getter和setter
getExportParameters()
setExportParameters()
Run Code Online (Sandbox Code Playgroud)
并在您的struts配置文件中声明映射如下
<param name="exportParameters ">exportParameters </param>
Run Code Online (Sandbox Code Playgroud)
休息框架会照顾希望这会对你有所帮助
| 归档时间: |
|
| 查看次数: |
2139 次 |
| 最近记录: |