我有
<table style="padding-top: 15px; padding-left: 50px; width: 1366px;">
<tr>
<thead>
<th>STT</th>
<th width="24%">Số tài khoản</th>
<th width="24%">Tên ngân hàng</th>
<th width="24%">Chi nhánh</th>
<th width="24%">Tỉnh/TP của ngân hàng</th>
</thead>
<tbody>
<tr th:each="item, itemStat : ${accountObjectForm.accountObjectBankAccountList}">
<td><span th:text="${itemStat.index + 1}"></span></td>
<td><input type="text" th:value="${accountObjectForm.accountObjectBankAccountList[0].bankAccount}" th:name="|accountObjectBankAccountList[${itemStat.index}].bankAccount|" th:id="|accountObjectBankAccountList[${itemStat.index}].bankAccount|" class="k-textbox" style="width: 100%;"></td>
<td><input type="number" th:name="|accountObjectBankAccountList[${itemStat.index}].bankId|" th:id="|accountObjectBankAccountList[${itemStat.index}].bankId|" class="k-textbox" style="width: 100%"></td>
<td><input type="text" th:name="|accountObjectBankAccountList[${itemStat.index}].bankBranchName|" th:id="|accountObjectBankAccountList[${itemStat.index}].bankBranchName|" class="k-textbox" style="width: 100%;"></td>
<td><input type="text" th:name="|accountObjectBankAccountList[${itemStat.index}].province|" th:id="|accountObjectBankAccountList[${itemStat.index}].province|" class="k-textbox" style="width: 100%;"></td>
</tr>
<script>
$(document).ready(function () {
var dataBank = new kendo.data.DataSource({
transport: {
read: {
url: "/banks_json",
dataType: "json"
}
},
pageSize: 30
});
$("input[name$='bankId']").each(function() {
$(this).kendoDropDownList({
optionLabel: "Chọn...",
dataTextField: "bankCode",
dataValueField: "id",
dataSource: dataBank,
index: 0,
change: onChangeBank
})
});
var dataProvinceBank = new kendo.data.DataSource({
transport: {
read: {
url: "/provinces",
dataType: "json"
}
},
pageSize: 300
});
$("input[name$='province']").each(function() {
$(this).kendoDropDownList({
optionLabel: "Chọn...",
dataTextField: "text",
dataValueField: "value",
filter: "contains",
dataSource: dataProvinceBank,
index: 0,
change: onChangeProvinceBank
})
});
});
function onChangeBank() { }
function onChangeProvinceBank() { }
</script>
</tbody>
</tr>
</table>
(在新选项卡中打开图像以查看更大的屏幕截图)
我试试
<td><input type="text" th:value="${accountObjectForm.accountObjectBankAccountList[${itemStat.index}].bankAccount}" th:name="|accountObjectBankAccountList[${itemStat.index}].bankAccount|" th:id="|accountObjectBankAccountList[${itemStat.index}].bankAccount|" class="k-textbox" style="width: 100%;"></td>
但是错误,当捕获这些代码行时,页面无法渲染为 html。
我使用 0
作为支架。请帮我通过列表索引更改数字0
。
th:value="${accountObjectForm.accountObjectBankAccountList[0].bankAccount}"
最佳答案
省略表达式中的内部${...}
大括号,直接引用itemStat.index
。您已经在使用 thymeleaf 表达式语法,无需使用两次。
不确定这是否是您的代码的唯一问题,但肯定首先要修复
关于java - Thymeleaf 显示列表对象的字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56912986/