TemplateInputException when Thymeleaf SpringTemplateResolver cannot resolve login template
0 reputation · 15 May 2020, 23:13 UTC
Thymeleaf TemplateInputException behavior with throwExceptionIfNotFound
The goal is to understand whether Thymeleaf should immediately throw a TemplateInputException when a template cannot be resolved, or whether it should permit a fallback view when throwExceptionIfNotFound is set to false, especially given that the default value changed between Thymeleaf 3.0.x and 3.1.x.
Constraints include the version‑dependent default, the effect of template caching on when the exception is surfaced, and the fact that a custom DatabaseTemplateResolver that relies on missing credentials will still propagate the same exception regardless of the flag.
Uncertainty remains about the recommended configuration for applications that want missing templates to be handled by a custom error view without exposing internal resolution failures, and how caching interacts with this setting in production versus test environments.
What value should throwExceptionIfNotFound be set to in a Spring Boot application using Thymeleaf 3.1.x to allow a custom error view to render instead of the exception?
How does enabling template caching (spring.thymeleaf.cache = true) affect the timing of the TemplateInputException when throwExceptionIfNotFound is false?
Should a DatabaseTemplateResolver that receives null credentials be expected to throw TemplateInputException even when throwExceptionIfNotFound is disabled?