Freemarker comes with a number of handlers for when an exception occurs in a template. You can also write your own handler for custom circumstances. This is all detailed in the Freemarker docs. Selecting an exception handlerSelection can be made through a freemarker.properties file in the root of you classpath (i.e. next to your xwork.xml). The property to set is template_exception_handler=rethrow The pre-defined choices are:
Descriptions taken from the Freemarker docs. If you wish to use a custom handler then you provide your fully qualififed class name. Rethrowing ExceptionsFor a production system it is often a good choice to use the rethrow handler. This prevents your stack trace being displayed to the user and allows you to present a friendly error screen. As of WebWork 2.2.6 when the rethrow handler is active then all output is buffered until the template is fully processed. This prevents parts of the template processed before an exception appearing in the view. If processing completes then the output is flushed to the writer. If an exception occurs then it is thrown out of the Freemarker Result Type and processed by the Exception Interceptor. See Exception Handling for details on how to present a friendly error screen. If you are using a custom result handler then the FreemarkerResultType provides a parameter bufferOutput which when set to true buffers all output, preventing unwanted content being written. |