带有转换特殊字符的 thymeleaf 错误消息
thymeleaf error message with converted special characters
我的网络应用程序(spring boot + thymeleaf)我使用 message_fr.properties 文件 包含一些转换为 html 的特殊字符
当我在 lang=fr
中显示错误验证消息时出现问题:
<span th:if="${#fields.hasErrors('title')}" th:errors="*{title}"></span>
假设 key/value 是:NotEmpty.item.title = Ne doit pas être null
在屏幕上它会显示错误消息而无需转换:Ne doit pas être null
我该如何解决?
th:errors
将以与 th:text
相同的方式转义 HTML。在 3.0.8 之前,您必须像这样迭代错误:
<span th:if="${#fields.hasErrors('title')}" th:each="err : ${#fields.errors('title')}"></span>
但是,post 3.0.8,Thymeleaf-Spring 包含 th:uerrors
用于未转义的错误消息,效果相同:
<span th:uerrors="*{title}"></span>
我的网络应用程序(spring boot + thymeleaf)我使用 message_fr.properties 文件 包含一些转换为 html 的特殊字符
当我在 lang=fr
中显示错误验证消息时出现问题:
<span th:if="${#fields.hasErrors('title')}" th:errors="*{title}"></span>
假设 key/value 是:NotEmpty.item.title = Ne doit pas être null
在屏幕上它会显示错误消息而无需转换:Ne doit pas être null
我该如何解决?
th:errors
将以与 th:text
相同的方式转义 HTML。在 3.0.8 之前,您必须像这样迭代错误:
<span th:if="${#fields.hasErrors('title')}" th:each="err : ${#fields.errors('title')}"></span>
但是,post 3.0.8,Thymeleaf-Spring 包含 th:uerrors
用于未转义的错误消息,效果相同:
<span th:uerrors="*{title}"></span>