【发布时间】:2015-05-27 10:30:28
【问题描述】:
目标:
将 4 位年份(例如 1999)字段设置为 LocalDate 控制器属性。如何在 Spring MVC 中将 input::1999 设置为 DateTime 对象?
JSP:
<form:form action="${url}" method="POST" commandName="form">
<form:input id="year" path="works[0].startDate.year"/>
</form:form>
SETTER: DateTime 更新为 4 位数年份
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class WorkRequest {
@DateTimeFormat(pattern = "MM/dd/yyyy")
@XmlElement(name = "start_date")
public DateTime startDate;
public void setStartDate(DateTime startDate){
//update 4-digit only
}
}
【问题讨论】:
-
你的问题是什么?
-
如何在 Spring MVC 中将 1999 设置为 DateTime 对象?
标签: java spring spring-mvc jodatime