关于jfinal使用sqlite的问题

为什么我前台传的22 后台int接收会出现下面的错误:

关键之前用mysql都是没问题的。

java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
	at com.jfinal.plugin.activerecord.Model.getInt(Model.java:207)
	at com.dcits.mvc.common.model.base.BaseServerInfo.getPort(BaseServerInfo.java:40)
	at com.dcits.mvc.common.service.ServerInfoService.checkRepeat(ServerInfoService.java:29)
	at com.dcits.mvc.common.controller.ServerInfoController.edit(ServerInfoController.java:36)
	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.validate.Validator.intercept(Validator.java:86)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.dcits.interceptor.GlobalInterceptor.intercept(GlobalInterceptor.java:17)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.jfinal.core.ActionHandler.handle(ActionHandler.java:83)
	at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:73)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
	at org.eclipse.jetty.server.Server.handle(Server.java:365)
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
	at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:937)
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:998)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
	at org.eclipse.jetty.util.thread.QueuedThr


评论区

白卡pala

2018-04-18 17:44

DruidPlugin druidPlugin = createDruidPlugin();
druidPlugin.setDriverClass("org.sqlite.JDBC");
/*druidPlugin.set(PropKit.getInt(ConstantInit.db_initialSize), PropKit.getInt(ConstantInit.db_minIdle),
PropKit.getInt(ConstantInit.db_maxActive));*/
me.add(druidPlugin);
logger.info("加载ActiveRecordPlugin插件...");
ActiveRecordPlugin arp = new ActiveRecordPlugin(druidPlugin);
//arp.setShowSql(true);
arp.setDialect(new Sqlite3Dialect());
_MappingKit.mapping(arp);
me.add(arp);

白卡pala

2018-04-18 17:44

@白卡pala 这是ActiveRecordPlugin 的配置

饺子包

2018-04-18 18:46

你数据库里是varchar吧,你又传int

热门分享

扫码入社