Как заставить ResourceResponse пересылать запрос на страницу ошибки в портлете liferay
Я пытаюсь перенаправить свой запрос на страницу ошибки, когда ошибка возникает во время создания таблицы Excel. Вот пример кода ниже. Я не уверен, почему он не перенаправляется на страницу ошибки, когда генерируется исключение, он отображает пустую страницу, но точно не заходит на мою страницу ошибки.
@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);
}
} }