Html Thymeleaf-SpringBoot中的绑定对象

Html Thymeleaf-SpringBoot中的绑定对象,html,spring,spring-mvc,spring-boot,thymeleaf,Html,Spring,Spring Mvc,Spring Boot,Thymeleaf,我已经使用SpringInitializer生成了一个SpringBootWeb应用程序,使用嵌入式Tomcat+Thymeleaf模板引擎,并将其打包为一个可执行的JAR文件 使用的技术: Spring Boot 1.4.2.RELEASE、Spring 4.3.4.RELEASE、Thymeleaf 2.1.5.RELEASE、Tomcat Embed 8.5.6、Maven 3、Java 8 我有这门课 public class AlarmNotification { priva

我已经使用SpringInitializer生成了一个SpringBootWeb应用程序,使用嵌入式Tomcat+Thymeleaf模板引擎,并将其打包为一个可执行的JAR文件

使用的技术:

Spring Boot 1.4.2.RELEASE、Spring 4.3.4.RELEASE、Thymeleaf 2.1.5.RELEASE、Tomcat Embed 8.5.6、Maven 3、Java 8

我有这门课

public class AlarmNotification {

    private Long id;

    private Action action;

    private Application aplication;

    private Device device;

    private TimeLapse timeLapse;

    private Guardian guardian;

    private List<SystemAlarm.Level> level;

    ...
}

我认为您的select标记中的th:值不正确,id设置不正确

对卫报来说应该是这样的

<select th:field="*{guardian}">
      <option th:each="guardian : ${guardians}" 
             th:value="${guardian.id}" 
             th:text="${guardian.name}"></option>
</select>
因为时间点应该这样宣布

<select th:field="*{timeLapse}">
     <option th:each="timeLapse : ${timeLapses}" 
         th:value="${timeLapse.id}" 
         th:text="${timeLapse.description}"></option>
</select>  
<select th:field="*{level}" multiple="multiple">
             <option th:each="level : ${alarmLevels}" 
                 th:value="${level}" 
                 th:text="${level}"></option>
        </select>
就水平而言,我认为你通过了错误的领域

<select th:field="*{timeLapse}">
     <option th:each="timeLapse : ${timeLapses}" 
         th:value="${timeLapse.id}" 
         th:text="${timeLapse.description}"></option>
</select>  
<select th:field="*{level}" multiple="multiple">
             <option th:each="level : ${alarmLevels}" 
                 th:value="${level}" 
                 th:text="${level}"></option>
        </select>

我希望这有帮助。

我认为您的select标记中的th:值不正确,id设置不正确

对卫报来说应该是这样的

<select th:field="*{guardian}">
      <option th:each="guardian : ${guardians}" 
             th:value="${guardian.id}" 
             th:text="${guardian.name}"></option>
</select>
因为时间点应该这样宣布

<select th:field="*{timeLapse}">
     <option th:each="timeLapse : ${timeLapses}" 
         th:value="${timeLapse.id}" 
         th:text="${timeLapse.description}"></option>
</select>  
<select th:field="*{level}" multiple="multiple">
             <option th:each="level : ${alarmLevels}" 
                 th:value="${level}" 
                 th:text="${level}"></option>
        </select>
就水平而言,我认为你通过了错误的领域

<select th:field="*{timeLapse}">
     <option th:each="timeLapse : ${timeLapses}" 
         th:value="${timeLapse.id}" 
         th:text="${timeLapse.description}"></option>
</select>  
<select th:field="*{level}" multiple="multiple">
             <option th:each="level : ${alarmLevels}" 
                 th:value="${level}" 
                 th:text="${level}"></option>
        </select>
我希望这有帮助。

知道为什么吗?知道为什么吗?