Spring 在按钮上单击“绑定列表”可将其绑定到文件夹中
我想要的是当我点击Spring 在按钮上单击“绑定列表”可将其绑定到文件夹中,spring,spring-boot,spring-mvc,thymeleaf,Spring,Spring Boot,Spring Mvc,Thymeleaf,我想要的是当我点击id=addUnitCharge按钮时,id=proName和id=proAge应该添加到id=property\u type\u tbl主体中。当我点击提交按钮时,所有值都应该分配给(id=code和id=school作为值和id=property\u type\u tbl值分配给unitCharge列表) 这是我的班 public class PlAccount{ private String code; private String school;
id=addUnitCharge
按钮时,id=proName
和id=proAge
应该添加到id=property\u type\u tbl
主体中。当我点击提交按钮时,所有值都应该分配给(id=code
和id=school
作为值和id=property\u type\u tbl
值分配给unitCharge
列表)
这是我的班
public class PlAccount{
private String code;
private String school;
private List<UnitCharge> unitCharge;
//Getters and Setters
}
我的控制器类
@GetMapping(path = {"/product/add")
public String index(Model model) {
model.addAttribute("type", PlAccount.builder().build());
return "/loan/product/add";
}
@PostMapping("/coopmis/waterTariff/product/add")
public String save(@Valid PlAccount plAccount, BindingResult result){
plAccountService.savePlAccount(plAccount);
}
我的html
<form method="post" action="/product/add" th:object="${type}">
<input type="number" id="code" class="form-control" th:name="code">
<input type="number" id="school" class="form-control" th:name="school">
//On button click below Items should add to `property_type_tbl` table.
<input type="number" id="proName" class="form-control" th:name="proName">
<input type="number" id="proAge" class="form-control" th:name="proAge">
<button type="button" class="btn btn-success" id="addUnitCharge" onclick="addRowPropertyType()"
th:text="#{add}">Add
</button>
<div class="form-group">
<button type="submit" class="btn btn-success " th:text="#{submit}">Submit</button>
</div>
</form>
<div class="form-group">
<table class="table table-striped id="property_type_tbl">
<thead>
<tr>
<th th:text="#{proName}"></th>
<th th:text="#{proAge}"></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
//单击下面的按钮,项目应添加到“属性类型”表中。
添加
提交
你已经试过什么了?到底什么不起作用?你已经试过什么了?到底是什么不起作用?
<form method="post" action="/product/add" th:object="${type}">
<input type="number" id="code" class="form-control" th:name="code">
<input type="number" id="school" class="form-control" th:name="school">
//On button click below Items should add to `property_type_tbl` table.
<input type="number" id="proName" class="form-control" th:name="proName">
<input type="number" id="proAge" class="form-control" th:name="proAge">
<button type="button" class="btn btn-success" id="addUnitCharge" onclick="addRowPropertyType()"
th:text="#{add}">Add
</button>
<div class="form-group">
<button type="submit" class="btn btn-success " th:text="#{submit}">Submit</button>
</div>
</form>
<div class="form-group">
<table class="table table-striped id="property_type_tbl">
<thead>
<tr>
<th th:text="#{proName}"></th>
<th th:text="#{proAge}"></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>