1.html
添加 th:fragment=“formfragment”,值与id保持一致
<div th:fragment="formFragment" id="formFragment">
<form id="form" th:object="${pojoName}">
<div th:if="${pojoName.id != null}">
<h2>报关总金额</h2>
<table>
<tr>
<td align="right">货值总额</td>
<td>
<input type="text" th:field="*{totalPrice}"/>
</td>
<td align="right">总佣金</td>
<td>
<input th:field="*{totalUsePrice}"/>
</td>
<td align="right">总运费</td>
<td>
<input type="text" th:field="*{fee}" />
</td>
<td align="right">总less金额</td>
<td>
<input type="text" th:field="*{lessPrice}" />
</td>
</tr>
</table>
</div>
</form>
</div>
2.js
function refreshFragment(headid) {
$.ajax({
url: ctxPath + "/member/input/formFragment?" + "headId=" + headid,
type: "post",
success: function (data) {
$("#formFragment").html(data);
}
})
}
3.java
@PostMapping(value = "/formFragment")
public String loadHead(@RequestParam(name = "headId") String headId, ModelMap model) {
TZcwlHead head = inputService.getById(headId);
model.addAttribute("pojoName", head);
return "member/input/editUltra::tydjefragment";
}