spring mvc 日期格式,格式为:输入 [英] spring mvc date format with form:input
本文介绍了spring mvc 日期格式,格式为:输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有休眠实体和一个 bean:
I have hibernate entity and a bean:
@Entity
public class GeneralObservation {
@DateTimeFormat(pattern = "dd/MM/yyyy")
Date date;
@Column
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
我也有
@InitBinder
protected void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
binder.registerCustomEditor(Date.class, new CustomDateEditor(
dateFormat, false));
}
和
form:input
id = "datepicker"
name="date"
itemLabel="date"
path="newObservation.date"
当我转到我的网址时,我看到:
When I go to my url I see:
如何强制它使用 mm/DD/yyyy 格式?谢谢
How can I force it to have mm/DD/yyyy format? Thanx
推荐答案
解决办法是把
到mvc-dispatcher-servlet.xml还有 xmlns:mvc="http://www.springframework.org/schema/mvc"到 xml 文件的开头.
The solution is to put
<mvc:annotation-driven/>
to
mvc-dispatcher-servlet.xml
and also xmlns:mvc="http://www.springframework.org/schema/mvc"
to the begining of xml file.
这篇关于spring mvc 日期格式,格式为:输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文