【发布时间】:2023-06-30 23:19:02
【问题描述】:
在生成 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); } } }
【问题讨论】:
标签: java model-view-controller portlet liferay-6 forward