前台传入日期参数查询报异常

x001 发布于 2016/01/04 08:52
阅读 532
收藏 0

@JFinal 你好,想跟你请教个问题:项目使用sqlserver2008库,JFinal使用2.1版,controller 使用getModel获取数据,报如下异常,经查看代码,是一个转换类异常,Interceptor : com.jfinal.ext.interceptor.SessionInViewInterceptor.(SessionInViewInterceptor.java:1)
              com.njsoft.mhis2.wechat.interceptor.AuthInterceptor.(AuthInterceptor.java:1)
Parameter   : attr.statisTime=2016-01-03  attr.endTime=2016-01-03  
--------------------------------------------------------------------------------


2016-01-03 22:41:32
[ERROR]-[Thread: http-apr-8080-exec-2]-[com.jfinal.core.ActionHandler.handle()]: /outpats
java.lang.RuntimeException: Can not convert parameter: attr.statisTime
at com.jfinal.core.ModelInjector.injectActiveRecordModel(ModelInjector.java:102)
at com.jfinal.core.ModelInjector.inject(ModelInjector.java:50)
at com.jfinal.core.Controller.getModel(Controller.java:654)
at com.njsoft.mhis2.wechat.controller.BaseController.getModelByAttr(BaseController.java:84)
at com.njsoft.mhis2.wechat.controller.HomeController.outpats(HomeController.java:84)
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:606)
at com.jfinal.aop.Invocation.invoke(Invocation.java:71)
at com.njsoft.mhis2.wechat.interceptor.AuthInterceptor.intercept(AuthInterceptor.java:59)
at com.jfinal.aop.Invocation.invoke(Invocation.java:65)
at com.jfinal.ext.interceptor.SessionInViewInterceptor.intercept(SessionInViewInterceptor.java:44)
at com.jfinal.aop.Invocation.invoke(Invocation.java:65)
at com.jfinal.core.ActionHandler.handle(ActionHandler.java:74)
at com.jfinal.plugin.druid.DruidStatViewHandler.handle(DruidStatViewHandler.java:75)
at com.jfinal.ext.handler.ContextPathHandler.handle(ContextPathHandler.java:47)
at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2522)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2511)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh🇲🇲ss[.fffffffff]
at java.sql.Timestamp.valueOf(Timestamp.java:202)
at com.jfinal.core.TypeConverter.convert(TypeConverter.java:93)
at com.jfinal.core.ModelInjector.injectActiveRecordModel(ModelInjector.java:98)
... 35 more

加载中
0
迷茫的中年IT狗
迷茫的中年IT狗
参数问题,格式不对
0
x001
x001

引用来自“腾讯公告”的评论

参数问题,格式不对
不是参数问题,是使用getModel接收前端日期查询条件时,一般前端都是以这样格式的:’yyyy-mm-dd‘日期传到后台的,但因为框架自动转换类,除mysql之外的其它库支持,必须是以这样格式:yyyy-mm-dd hh:mm:ss[.fffffffff]日期返回,所以就抛出的异常。
x001
x001
回复 @腾讯公告 : 当然是能自己处理getPara,使用getModel方便多,但这个问题的确是一个日期转换格式bug。
迷茫的中年IT狗
迷茫的中年IT狗
自己处理一下这个数据
返回顶部
顶部