Thymeleaf 添加带有消息资源值的自定义数据属性
Thymeleaf add custom data attribute with message resource value
我有一个要求,我需要使用 thymeleaf 将值插入自定义数据标签。使用
的代码
data-th-attr="${data-custom=#messages.msg('test')}"
以及
th:attr="data-custom=${#messages.msg('test')}"
我无法在这两种情况下获取值。
最终解析应该像 data-custom="test"
此处测试是属性文件中值测试的关键
使用 th:attr="data-custom=#{key.for.message}" ,这应该有效。
然后在解析表达式后,
数据自定义="value.for.message"
通过使用
data-th-attr="data-custom=#{test}"
或使用
th:attr="data-custom=#{test}"
帮了我大忙,这里的测试是消息资源中值的关键,问题出在 intellij IDEA IDE,它有一个错误,向我显示了一个不必要的错误.
我有一个要求,我需要使用 thymeleaf 将值插入自定义数据标签。使用
的代码 data-th-attr="${data-custom=#messages.msg('test')}"
以及
th:attr="data-custom=${#messages.msg('test')}"
我无法在这两种情况下获取值。
最终解析应该像 data-custom="test"
此处测试是属性文件中值测试的关键
使用 th:attr="data-custom=#{key.for.message}" ,这应该有效。
然后在解析表达式后,
数据自定义="value.for.message"
通过使用
data-th-attr="data-custom=#{test}"
或使用
th:attr="data-custom=#{test}"
帮了我大忙,这里的测试是消息资源中值的关键,问题出在 intellij IDEA IDE,它有一个错误,向我显示了一个不必要的错误.