如何在thymeleaf中填写input type=“time”字段?

mm5n2pyu  于 2021-06-29  发布在  Java
关注(0)|答案(0)|浏览(236)

打开html表单时,spring boot+eleaf项目不会填充input type=“time”字段。这就是它的工作原理:

<input type="time" class="form-control" id="inputTime" th:value=${CarEntity.timeOperation} required>

这里是:

<input type="time" class="form-control" id="inputTime" th:field="*{timeOperation}" required>

大概是这样:

<input type="time" class="form-control" id="inputTime" th:field="*{timeOperation}" th:value=${CarEntity.timeOperation} required>

字段仍为空。如果我使用,那么一切都正常。

<form id="f-pr-03" th:method="POST" th:action="@{/edit/{id}(id=${carEntity.getId()})}" th:object="${carEntity}">
That's how everything works and displays and reads.
    <label for="inputName">Input name</label>
    <input type="text" class="form-control" id="inputName" th:field="*{name}" required>

But this is not displayed
    <label for="inputPTTime">Input time</label>
    <input type="time" class="form-control" id="inputPTTime" th:field="*{timeOperation}" max="17:50" min="00:01" required>

And this is how it is displayed, but not transmitted by the POST method 
    <label for="inputPTTime">Input time</label>
    <input type="time" class="form-control" id="inputPTTime" th:value=${CarEntity.timeOperation} max="17:50" min="00:01" required>
    <button type="submit" name="action">Save</button>
</form>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题