Wie man die ResourceResponse veranlasst, die Anfrage an die Fehlerseite im Liferay-Portlet weiterzuleiten

Ich versuche, meine Anfrage an die Fehlerseite weiterzuleiten, wenn beim Generieren des Excel-Blatts ein Fehler auftritt. Hier ist ein Beispielcode unten. Ich bin nicht sicher, warum es nicht zur Fehlerseite weitergeleitet wird, wenn die Ausnahme ausgelöst wird. Es wird eine leere Seite angezeigt, aber es wird nicht sicher zu meiner Fehlerseite gewechselt. "

        @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);
            } 
        } }

Antworten auf die Frage(4)

Ihre Antwort auf die Frage