Package org.apache.struts2.dispatcher
Class DefaultDispatcherErrorHandler
java.lang.Object
org.apache.struts2.dispatcher.DefaultDispatcherErrorHandler
- All Implemented Interfaces:
DispatcherErrorHandler
Default implementation of
DispatcherErrorHandler
which sends Error Report in devMode or HttpServletResponse.sendError(int, java.lang.String) otherwise.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateReportData(Exception e, List<Throwable> chain) protected freemarker.template.TemplateLoads the problem report template on first use rather than at startup: it is only ever rendered in devMode, so a production application should never build a FreeMarker configuration on its behalf.voidhandleError(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, int code, Exception e) Handle passed error code or exceptionprotected voidhandleErrorInDevMode(jakarta.servlet.http.HttpServletResponse response, int code, Exception e) voidinit(jakarta.servlet.ServletContext ctx) Init instance after creatingDispatcherprotected voidsendErrorResponse(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, int code, Exception e) voidsetDevMode(String devMode) voidsetFreemarkerManager(FreemarkerManager freemarkerManager)
-
Constructor Details
-
DefaultDispatcherErrorHandler
public DefaultDispatcherErrorHandler()
-
-
Method Details
-
setFreemarkerManager
-
setDevMode
-
init
public void init(jakarta.servlet.ServletContext ctx) Description copied from interface:DispatcherErrorHandlerInit instance after creatingDispatcher- Specified by:
initin interfaceDispatcherErrorHandler- Parameters:
ctx- currentServletContext
-
getTemplate
Loads the problem report template on first use rather than at startup: it is only ever rendered in devMode, so a production application should never build a FreeMarker configuration on its behalf.Synchronised rather than lock-free: this runs only when devMode is on and a request has already failed, and
FreemarkerManager.getConfiguration(ServletContext)is itself synchronised, so the lock costs nothing that this path was not paying already.- Returns:
- the problem report template
- Throws:
IOException- if the template cannot be loaded
-
handleError
public void handleError(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, int code, Exception e) Description copied from interface:DispatcherErrorHandlerHandle passed error code or exception- Specified by:
handleErrorin interfaceDispatcherErrorHandler- Parameters:
request- currentHttpServletRequestresponse- currentHttpServletResponsecode- HTTP Error Code, seeHttpServletResponsefor possible error codese- Exception to report
-
sendErrorResponse
protected void sendErrorResponse(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, int code, Exception e) -
handleErrorInDevMode
protected void handleErrorInDevMode(jakarta.servlet.http.HttpServletResponse response, int code, Exception e) -
createReportData
-