-1
我其实有两个问题。两者都发生在相同的情况下,如下所示:春天转换成表格支持bean
我正在与春天和thymeleaf,我想发布一个窗体到服务器,这工作正常,但服务器无法转换一些submited数据到我的bean属性的类型。
形式:
<form th:action="@{/demo}}"
th:object="${myBean}" method="post">
<label>date</label>
<input type="date" th:field="*{date}">
<label>type</label>
<select th:filed="*{type}">
<option th:each="type: ${types}"
th:value="${type.id}" th:text="${type.name}"</option>
</select>
<button type="submit">Submit</button>
</form>
的的BeanDefinition:
@lombok.Data
public class MyBean{
private ZonedDateTime date;
private MyType type;
}
问题:
- 日期输入的值不能转化为java.time.ZonedDateTime
- select(它将作为数字发布)的值ca n不能转换为MyType类型的对象。我会推测这是因为MyType是一个JPA实体,并为其定义了一个
org.springframework.data.repository.CrudRepository
。
如果你们中的任何一位能帮助我,我会很高兴。