我试图在spring boot中使用自动配置的服务静态内容.我读过它就足以将该内容放入/static/
或/resources/
配置@Controller
以便执行此操作.
在我的项目中,它看起来根本不起作用.
我把它与它进行spring-boot-sample-web-ui
了比较,我唯一不同的是包装.有jar
和我有war
包装.
你能否确认我在war
包装中的spring-boot中这个自动配置的静态内容服务不起作用?
我正在使用JasperReports生成一个报告,并假设将其导出为多种格式.但目前我只使用excel报告.
这是我的控制器代码.
InputStream in = reportTemplate.getTemplate(reportInquery.getTemplateFile());
JasperPrint print = JasperFillManager.fillReport(in, null,
new JRResultSetDataSource(reportDao.getReportData(reportInquery)));
resp = HttpConfig.setHeaders(reportInquery, resp);
Exporter exporter = reportOption.getRenderOptions(reportInquery.getFormat(), resp.getOutputStream(), print);
exporter.exportReport();
Run Code Online (Sandbox Code Playgroud)
在我的配置工厂中,excel报告在调用getRenderOptions
方法后配置如下.
public Exporter exporterOptions(OutputStream outputStream, JasperPrint print) {
JRXlsExporter exporter = new JRXlsExporter();
exporter.setExporterInput(new SimpleExporterInput(print));
OutputStreamExporterOutput outputStreamExporterOutput = new SimpleOutputStreamExporterOutput(outputStream);
exporter.setExporterOutput(outputStreamExporterOutput);
SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
configuration.setOnePagePerSheet(true);
configuration.setDetectCellType(true);
configuration.setMaxRowsPerSheet(100);
configuration.setRemoveEmptySpaceBetweenColumns(true);
configuration.setRemoveEmptySpaceBetweenRows(true);
exporter.setConfiguration(configuration);
return exporter;
}
Run Code Online (Sandbox Code Playgroud)
创建JRResultSetDataSource
我OracleCachedRowSet
在上面的getReportData
方法中使用了oracle .
public RowSet getReportData(ReportInqueryDTO reportInquery) {
try {
String query …
Run Code Online (Sandbox Code Playgroud) 我有一系列像这样的哈希.
[
{"package_details"=>{"name"=>"Package3", "price"=>3000.0, "id"=>"281"},"event_id"=>336},
{"package_details"=>{"name"=>"2000/-", "price"=>2000.0, "id"=>"280"}, "event_id"=>337},
{"package_details"=>{"name"=>"Package1", "price"=>1000.0, "id"=>"282"},"event_id"=>337},
{"package_details"=>{"name"=>"Package2", "price"=>2000.0, "id"=>"283"},"event_id"=>337}
]
Run Code Online (Sandbox Code Playgroud)
我希望这就像这样.
[
{"event_id"=>336, "package_details"=>[
{"name"=>"Package3", "price"=>3000.0, "id"=>"281"}
]},
{"event_id"=>337, "package_details"=>[
{"name"=>"2000/-", "price"=>2000.0, "id"=>"280"},
{"name"=>"Package1", "price"=>1000.0, "id"=>"282"},
{"name"=>"Package2", "price"=>2000.0, "id"=>"283"}
]},
]
Run Code Online (Sandbox Code Playgroud)
哈希应该根据相等的event_id
值进行合并,并且事件可以包含许多包.
我想知道最简单的方法.虽然我可以做很多if和else s.