易买网项目中添加jsp页面中格式化日期时,日期的格式不能有汉字,如2017年-08月-12日
2017-08-12 17:47
253 查看
错误:添加页面时出错
No property editor [java.util.DateEditor] found for type java.util.Date according to ‘Editor’ suffix convention
Resolving exception from handler [public java.lang.String com.ebuy.shopping.controller.NoticeController.add(org.springframework.ui.Model,com.ebuy.shopping.model.Notice)]: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object ‘notice’ on field ‘createTime’: rejected value [2017年-08月-12日 05:34:52]; codes [typeMismatch.notice.createTime,typeMismatch.createTime,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [notice.createTime,createTime]; arguments []; default message [createTime]]; default message [Failed to convert property value of type ‘java.lang.String’ to required type ‘java.util.Date’ for property ‘createTime’; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type @org.springframework.format.annotation.DateTimeFormat java.util.Date for value ‘2017年-08月-12日 05:34:52’; nested exception is java.lang.IllegalArgumentException: Unable to parse ‘2017年-08月-12日 05:34:52’]
Resolving exception from handler [public java.lang.String com.ebuy.shopping.controller.NoticeController.add(org.springframework.ui.Model,com.ebuy.shopping.model.Notice)]: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object ‘notice’ on field ‘createTime’: rejected value [2017年-08月-12日 05:34:52]; codes [typeMismatch.notice.createTime,typeMismatch.createTime,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [notice.createTime,createTime]; arguments []; default message [createTime]]; default message [Failed to convert property value of type ‘java.lang.String’ to required type ‘java.util.Date’ for property ‘createTime’; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type @org.springframework.format.annotation.DateTimeFormat java.util.Date for value ‘2017年-08月-12日 05:34:52’; nested exception is java.lang.IllegalArgumentException: Unable to parse ‘2017年-08月-12日 05:34:52’]
Resolving exception from handler [public java.lang.String com.ebuy.shopping.controller.NoticeController.add(org.springframework.ui.Model,com.ebuy.shopping.model.Notice)]: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object ‘notice’ on field ‘createTime’: rejected value [2017年-08月-12日 05:34:52]; codes [typeMismatch.notice.createTime,typeMismatch.createTime,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [notice.createTime,createTime]; arguments []; default message [createTime]]; default message [Failed to convert property value of type ‘java.lang.String’ to required type ‘java.util.Date’ for property ‘createTime’; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type @org.springframework.format.annotation.DateTimeFormat java.util.Date for value ‘2017年-08月-12日 05:34:52’; nested exception is java.lang.IllegalArgumentException: Unable to parse ‘2017年-08月-12日 05:34:52’
解决方法:
把日期中汉字去掉即可
注意:实体类和jsp页面都要进行日期格式化
当在公告列表显示的时候就不需要考虑这些了,日期格式有汉字也行
格式化日期方法:
实体类中:
@DateTimeFormat(pattern = “yyyy-MM-dd hh:mm:ss”)
private Date createTime;
添加的jsp页面中:
<% String time=new SimpleDateFormat(“yyyy年-MM月-dd日 hh:mm:ss”).format(new Date()) ;%>
把time放在value中即可
创建时间:
No property editor [java.util.DateEditor] found for type java.util.Date according to ‘Editor’ suffix convention
Resolving exception from handler [public java.lang.String com.ebuy.shopping.controller.NoticeController.add(org.springframework.ui.Model,com.ebuy.shopping.model.Notice)]: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object ‘notice’ on field ‘createTime’: rejected value [2017年-08月-12日 05:34:52]; codes [typeMismatch.notice.createTime,typeMismatch.createTime,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [notice.createTime,createTime]; arguments []; default message [createTime]]; default message [Failed to convert property value of type ‘java.lang.String’ to required type ‘java.util.Date’ for property ‘createTime’; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type @org.springframework.format.annotation.DateTimeFormat java.util.Date for value ‘2017年-08月-12日 05:34:52’; nested exception is java.lang.IllegalArgumentException: Unable to parse ‘2017年-08月-12日 05:34:52’]
Resolving exception from handler [public java.lang.String com.ebuy.shopping.controller.NoticeController.add(org.springframework.ui.Model,com.ebuy.shopping.model.Notice)]: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object ‘notice’ on field ‘createTime’: rejected value [2017年-08月-12日 05:34:52]; codes [typeMismatch.notice.createTime,typeMismatch.createTime,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [notice.createTime,createTime]; arguments []; default message [createTime]]; default message [Failed to convert property value of type ‘java.lang.String’ to required type ‘java.util.Date’ for property ‘createTime’; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type @org.springframework.format.annotation.DateTimeFormat java.util.Date for value ‘2017年-08月-12日 05:34:52’; nested exception is java.lang.IllegalArgumentException: Unable to parse ‘2017年-08月-12日 05:34:52’]
Resolving exception from handler [public java.lang.String com.ebuy.shopping.controller.NoticeController.add(org.springframework.ui.Model,com.ebuy.shopping.model.Notice)]: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object ‘notice’ on field ‘createTime’: rejected value [2017年-08月-12日 05:34:52]; codes [typeMismatch.notice.createTime,typeMismatch.createTime,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [notice.createTime,createTime]; arguments []; default message [createTime]]; default message [Failed to convert property value of type ‘java.lang.String’ to required type ‘java.util.Date’ for property ‘createTime’; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type @org.springframework.format.annotation.DateTimeFormat java.util.Date for value ‘2017年-08月-12日 05:34:52’; nested exception is java.lang.IllegalArgumentException: Unable to parse ‘2017年-08月-12日 05:34:52’
解决方法:
把日期中汉字去掉即可
注意:实体类和jsp页面都要进行日期格式化
当在公告列表显示的时候就不需要考虑这些了,日期格式有汉字也行
格式化日期方法:
实体类中:
@DateTimeFormat(pattern = “yyyy-MM-dd hh:mm:ss”)
private Date createTime;
添加的jsp页面中:
<% String time=new SimpleDateFormat(“yyyy年-MM月-dd日 hh:mm:ss”).format(new Date()) ;%>
把time放在value中即可
创建时间:
相关文章推荐
- 在jsp页面上格式化输出日期格式
- easyui-datagrid获取到日期格式的数据,在jsp页面进行格式化。
- jsp页面格式化时间 fmt:formatDate格式化日期
- jsp页面日期格式化
- 在JSP页面将时间戳转换成格式化日期
- 日期转换JSTL JSP 页面显示日期格式设置
- IDEA启用web项目不能即时刷新HTML或JSP页面问题
- JSP页面日期按格式显示!
- 把Json格式里的时间戳(13位)在JSP页面格式化显示YYY-MM-dd HH:mm:ss
- 解决IDEA打开web项目时不能随时刷新HTML或者JSP页面问题
- 在jsp页面如何转换日期格式
- JSP页面日期按格式显示!
- Jsp页面中超链接不能打开带汉字的文件的解决
- 项目开发技巧(五):jsp页面链接中文文件,不能打开中文文件的问题
- 日期转换JSTL JSP 页面显示日期格式设置
- jsp页面格式化日期 用jstl的fmt:formatDate 标签
- JSP页面日期按格式显示
- jsp页面日期格式化
- (待补全测试结果)crm小问题注意:add.jsp添加客户页面回显字典供选择。【查询字典时传参数typeCode不能和属性名相同】
- 在项目开发中,jsp页面不会少了,如何公用页面(添加页面和修改页面)和公用样式代码(css,js)?