Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 在按钮上单击“绑定列表”可将其绑定到文件夹中_Spring_Spring Boot_Spring Mvc_Thymeleaf - Fatal编程技术网

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>