【问题标题】:Transfer data in Thymeleaf在 Thymeleaf 中传输数据
【发布时间】:2018-10-15 06:04:18
【问题描述】:

我有两个这样的输入值

<input type="text" th:field="*{itemID}"placeholder="Bidding id" class="form- 
control" required />
------------
<input type="hidden" th:field="*{item.id}" />

好的,我怎样才能将 item.id 字段的值放入 itemID 中?我尝试如下,但没有成功

<input type="hidden" th:field="*{itemID}" th:value="*{item.id}" 
placeholder="Bidding id" class="form-control" required />

更新 我试着让它变成这样,但它仍然不起作用

<input type="hidden" th:name="*{itemID}" th:value="1"
placeholder="Bidding id" class="form-control" required />

【问题讨论】:

  • th:field 设置名称和值。如果您想手动执行此操作,请尝试设置 th:name 和 th:value
  • 它不起作用,先生
  • 你得到什么 html 输出?你期待什么?
  • 我尝试在eclipse中调试它,它说当我执行函数时itemID值总是等于0

标签: spring spring-mvc spring-boot thymeleaf


【解决方案1】:

试试这个:

<input type="hidden" th:field="*{itemID}" th:value="${item.id}" placeholder="Bidding id" class="form-control" required />

th:value 属性中将* 替换为$

【讨论】:

    猜你喜欢
    • 2020-06-20
    • 2016-12-02
    • 1970-01-01
    • 2019-02-28
    • 1970-01-01
    • 2019-01-28
    • 2017-10-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多