html - 输入类型 ="text"中的 Thymeleaf 占位符

标签 html thymeleaf

我在

中有这个输入文本
<input type="text" id="usernameId"  name="username" placeholder="User" />

我想从属性文件中替换占位符 User for 1 text 的文本,但不知道是否可行

<input type="text" id="usernameId"  name="username" placeholder="th:text="#{user.placeholder}""  />

最佳答案

有一个特定的 Thymeleaf 属性:

<input type="text" id="usernameId"  name="username" th:placeholder="#{user.placeholder}" />

也可以这样写:

<input type="text" id="usernameId"  name="username" th:attr="placeholder=#{user.placeholder}" />

关于html - 输入类型 ="text"中的 Thymeleaf 占位符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43810612/

相关文章:

javascript - IE9 检测不到 PC 上安装的字体

javascript - 隐藏发帖按钮是否是防止用户未经许可发帖的有效方法?

html - 需要将基于 HTML5 的 Web 应用程序转换为面向所有移动设备的移动应用程序

html - 对齐 div 的相对边缘

thymeleaf - Thymeleaf 中 #request.getParameters() 的解决方法

java - 如何从列表中取出列表?

java - 由于 spring security,无法访问 spring-boot 项目中的 Assets

java - Spring MVC + Thymeleaf - 保存关系@ManyToOne

javascript - 使用 html 和 javascript 添加星标

java - Spring启动Thymeleaf : How do I display an entity name from the database and make that name a hyperlink?