Код: Выделить всё
@ResourceMapping("xyz")
public void generateExcelExport(ResourceRequest request, ResourceResponse response) {
try {
//Do all the excel related logic
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setProperty("Content-Disposition", "attachment; filename=\"" + XYZ + "\"");
workbook.write(response.getPortletOutputStream());
} catch (Exception e) {
response.setProperty("Content-Disposition", "inline" );
response.setContentType("text/html");
PortletRequestDispatcher dispatcher = request.getPortletSession().getPortletContext().getRequestDispatcher("/WEB-INF/views/html/jsp/error.jsp");
try {
dispatcher.forward(request, response);
} catch (Exception e1) {
log.error("Unable to forward the request from the portlet", e1);
}
} }
Подробнее здесь: https://stackoverflow.com/questions/178 ... in-liferay