在生成 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); } } }