java - Thymeleaf 无法将 zoneddatetime 绑定到输入字段
问题描述
这是我的表格
<form th:action="@{/pages/org/create}" th:object="${org}" method="post" id="createOrgForm">
<div class="row">
<div class="form-group col-sm-12">
<label for="name">Name</label> <input class="form-control" id="name" type="text" th:field="*{name}" />
</div>
</div>
<div class="row">
<div class="form-group col-sm-12">
<label for="uuid">Uuid</label> <input class="form-control" id="uuid" type="text" th:field="*{uuid}" />
</div>
</div>
<div class="row">
<div class="form-group col-sm-12">
<label for="expiryDate">Expiry Date</label>
<input class="form-control" id="expiryDate" type="date" name="expiryDate" th:value="${#temporals.format(org.expiryDate, 'dd/MMM/yyyy HH:mm', 'en')}"/>/>
</div>
</div>
</form>
该对象具有名称和 uuid,它们是字符串它还有一个 expiryDate,它是 zonedDateTime
我想将 expiryDate 作为 zoneddatetime 返回,但我找不到任何示例
有人知道怎么做吗?
如果需要更多详细信息,请告诉我
我有这个错误
出现意外错误(类型=错误请求,状态=400)。object='org' 的验证失败。错误计数:1
因为 org.expiryDate 是一个字符串,它需要一个 zoneddatetime
public class OrganizationDto extends TemporallyScopedEntityFlatDto {
private static final long serialVersionUID = -2191341305487098272L;
public static OrganizationDto fromEntity(final Organization o) {
if (o == null) {
return null;
}
final OrganizationDto dto = new OrganizationDto();
DtoUtil.copyVersioned(o, dto);
DtoUtil.copyTemporallyScoped(o, dto);
dto.setName(o.getName());
dto.setUuid(o.getUuid());
return dto;
}
@ApiModelProperty(value = "The display name of this organization.")
private String name;
@ApiModelProperty(value = "The unique identifier of this organization.")
private String uuid;
private ZonedDateTime expiryDate;
public String getName() {
return name;
}
public String getUuid() {
return uuid;
}
public void setName(final String name) {
this.name = name;
}
public void setUuid(final String uuid) {
this.uuid = uuid;
}
}
解决方案
推荐阅读
- java - 在几个节点之前插入到 InsnList
- python - 保存图像文件时在 Flask 中出现错误“ValueError:读取已关闭文件”
- javascript - 如何在 JavaScript 中创建对象数组?
- nlp - 尽管使用了“ContextDependentTokenizerAnnotator”,但为什么 Ctakes 无法识别:“结肠直肠癌”医学文本?
- websphere - WebSphere Application Server 对 MicroProfile 的支持
- javascript - 无法在 ReactJS 中上传多个文件(使用不同的上传器组件)
- c - fprintf 打印以在正确输出的中间归档一个垃圾值
- ruby-on-rails - 序列化一对多关联的最后一条记录
- date - 有哪些闰年错误的例子?
- pandas - 熊猫用过滤器用最常见的值填充缺失值?