model日期类型获取错误问题

public void setAppointtime(java.util.Date appointtime) {
	set("appointtime", appointtime);
}
public java.util.Date getAppointtime() {
	return get("appointtime");
}

这是model的get和set

数据库是mysql的,字段类型为datetime;

昨天刚从2.2版本升级为3.0,今天就出现了获取数据类型错误的问题;

2017-03-23 09:16:32
[ERROR]-[Thread: http-bio-8080-exec-10]-[com.jfinal.core.ActionHandler.handle()]: /appoint/addAppoint
java.lang.RuntimeException: Can not convert parameter: appoint.appointtime
	at com.jfinal.core.Injector.injectModel(Injector.java:135)
	at com.jfinal.core.Controller.getModel(Controller.java:709)
	at job.tot.controller.AppointController.addAppoint(AppointController.java:60)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:73)
	at com.jfinal.core.ActionHandler.handle(ActionHandler.java:74)
	at com.jfinal.ext.handler.ContextPathHandler.handle(ContextPathHandler.java:48)
	at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:74)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]
	at java.sql.Timestamp.valueOf(Timestamp.java:202)
	at com.jfinal.core.TypeConverter.convert(TypeConverter.java:100)
	at com.jfinal.core.Injector.injectModel(Injector.java:131)
	... 26 more


评论区

zhongshg

2017-03-23 10:12

补充:发现所有数据库字段为datetime的都获取为timestamp,能力有限,debug晕了,没找到原因,是3.0版本跟2.2版本有什么变动吗?

zhongshg

2017-03-23 10:23

补充:换回2.2版本的jfinal之后问题不再出现,说明是版本升级导致的,3.0版本跟2.0版本有冲突的地方

JFinal

2017-03-23 11:04

是 H5 插件的问题,时间格式是 yyyy-mm-ddThh:mm:ss,中间多出来一个 "T",所以不支持

热门反馈

扫码入社