Thymeleaf - 自定义属性 [英] Thymeleaf - custom attribute

查看:59
本文介绍了Thymeleaf - 自定义属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从消息资源中设置自定义属性(数据验证匹配消息)值.

I need to set custom attribute (data-validation-matches-message) value from messages resources.

<input data-validation-matches-message="Text from messages resources" />

我可以接收和打印消息资源值:

I can receive and print messages resources value as:

<p th:text="#{user.notfound}"></p>

但是如何为自定义属性(数据验证匹配消息)设置此值?

But how I can set this value for a custom attribute (data-validation-matches-message)?

UPD(我用这个)

<input th:attr="data-validation-matches-message=#{user.notfound}"/>

推荐答案

试试这个:

<input th:attr="data-validation-matches-message='\'' + #{user.notfound}" + '\''"/>

这篇关于Thymeleaf - 自定义属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆