В проекте Struts 2 я пытаюсь экспортировать PDF и Excel. Для таких данных, как 15000, он работает нормально, но если данные превышают 50000, он выдает исключение.
java.lang.IllegalArgumentException: Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the <param name="inputName"> tag specified for this action
Конфигурация Struts.xml.
<result name="success" type="stream">
<param name="contentType">application/vnd.ms-excel</param>
<param name="inputName">inputStream</param>
<param name="contentDisposition">attachment;filename="ActivitiesList.xls"</param>
<param name="bufferSize">4096</param>
</result>
Service.java
public HSSFWorkbook exportInExcel(ActivitiesReportDTO activitiesReportDTO) throws Exception {
CreateExcelHelper cEH = new CreateExcelHelper("Activities List");
HSSFWorkbook workbook = null;
workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Activities List");
HSSFCellStyle cellStyleHeader = cEH.getColHeaderStyle(workbook);
HSSFCellStyle cellStyleCol = cEH.getColStyle(workbook);
int headerRowCounter = 0;
HSSFRow row = sheet.createRow(2);
cEH.getExcelCellStr(row,0,cellStyleHeader,"Sr No");
int i = 0;
for(EmployeeActivityLogDTO dto : listOfActivities){
row = sheet.createRow((short)++rowIndex);
int dataRowCounter = 0;
cEH.getExcelCellNum(row,0,cellStyleCol,++i);
cEH.getExcelCellStr(row,++dataRowCounter,cellStyleCol,dto.getNtLogin());
}
return workbook;
}
Action.java (это метод в strutsaction.java)
public String exportInExcel() {
try {
HSSFWorkbook workbook = activitiesReportService.exportInExcel(activitiesReportDTO);
ByteArrayOutputStream boas = new ByteArrayOutputStream();
workbook.write(boas);
setInputStream(new ByteArrayInputStream(boas.toByteArray()));
} catch (Exception e) {
logger.error("Exception Occured :", e);
}
return SUCCESS;
}