Я использую весеннюю загрузку 1.5, я хочу загрузить csv-файл предупреждений (class alert) с конкретными идентификаторами, которые я указываю в URL, но он всегда дает мне только первое предупреждение с первым идентификатором в параметрах запроса:например, если я хочу загрузить оповещения с идентификаторами 32 и 65, я только что получил csv-файл с оповещением с идентификатором 32, я не знаю, что с кодом, пожалуйста, помогите.
служба:
@Override
public InputStream exportAlerts(Long id) throws IOException {
List<ExportSuggestVO> exportSuggestVOS = new ArrayList<>();
final String[] header = new String[]{"id", "alertStatus","added","addedByEmail", "addedBy",
"uo" , "assigneeMatricule", "closed", "object", "content"};
final CellProcessor[] processors = getProcessors();
Alert alert = alertRepository.findById(id);
{
exportSuggestVOS.add(new ExportSuggestVO.Builder()
.setId(alert.getId() == null ? null : alert.getId())
.setAlertStatus(alert.getAlertStatus() == null ? " "
: alert.getAlertStatus().getLabel())
.setAdded(alert.getAdded() == null ? " "
: alert.getAdded().toString().replace("T", " "))
.setAddedBy(alert.getAddedBy() == null ? " "
: alert.getAddedBy())
.setAddedByEmail(intelciaCoreService.getEmployeeDetails(alert.getAddedBy()) == null ? " "
: intelciaCoreService.getEmployeeDetails(alert.getAddedBy()).getEmail())
.setUo(intelciaCoreService.getEmployeeDetails(alert.getAddedBy()) == null ? " "
: intelciaCoreService.getEmployeeDetails(alert.getAddedBy()).getUo())
.setAssigneeMatricule(alert.getAssignee() == null ? " "
: alert.getAssignee())
.setClosed(alert.getClosed() == null ? " "
: alert.getClosed().toString().replace("T", " "))
.setObject(alert.getObject() == null ? " "
: alert.getObject())
.setContent(alert.getDescription() == null ? " "
: alert.getDescription())
.build());}
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
CsvBeanWriter beanWriter = null;
try{
beanWriter = new CsvBeanWriter(new OutputStreamWriter(outputStream, "ISO-8859-1"),
CsvPreference.EXCEL_NORTH_EUROPE_PREFERENCE);
beanWriter.writeHeader("Id", "Status", "Date de creation", "Auteur", "Auteur-email", "Site/UO",
"Assignee", "Date de fermeture" ,"Objet" , "Contenu");
for (ExportSuggestVO exportSuggestVO : exportSuggestVOS){
beanWriter.write(exportSuggestVO, header,processors);
}
} finally {
if (beanWriter != null){
beanWriter.close();
}
}
return new ByteArrayInputStream(outputStream.toByteArray()); }
контроллер:
@RequestMapping(value = "/massiveDownload{ids}", method = RequestMethod.GET)
public void massiveExport(@RequestParam List<Long> ids, HttpServletResponse response)
throws IOException
{
for (Long id : ids) {
InputStream in = alertService.exportAlerts(id);
try {
response.setContentType("text/csv;charset=UTF-8");
response.addHeader("Content-Disposition", "attachment; filename = Alerts" + LocalDate.now() + ".csv");
OutputStream outputStream = response.getOutputStream();
IOUtils.copy(new BufferedInputStream(in), outputStream);
in.close();
outputStream.flush();
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}}
ps: когда я отлаживаю, контроллер распознает все идентификаторы.