John
John

Reputation: 1888

Custom error page using Thymeleaf

I'm messing around with adding a custom error page to a Spring Boot project and I was curious if I need to do anything other than just create a new error.html page.

I want the page to change for different messages obviously. But I noticed (on accident) that something like <h1 th:text="#{error.status_code}">404</h1> returns me ??error.status_code_en_US??. Which I'm assuming is the status_code but not in a readable way or something? Is it possible to get that from just an error.html page?

Some more..

<p  th:text="#{error.exception}">Default Error Message</p>
<p  th:text="#{error.exception_type}">Default Error Message</p>
<p  th:text="#{error.request_uri}">Default Error Message</p>
<p  th:text="#{error.servlet_name}">Default Error Message</p>

Generates:

??error.exception_en_US??
??error.exception_type_en_US??
??error.request_uri_en_US??
??error.servlet_name_en_US??

Upvotes: 0

Views: 1414

Answers (1)

DarkAtra
DarkAtra

Reputation: 1232

#{} refers to the i18n implementation and tries to resolve the given string from your message bundles. To evaluate this using the SpringEL you have to use ${}.

Upvotes: 2

Related Questions