配置如下:
me.setJsonFactory(new FastJsonFactory());
Model 中定义方法
public List<MemberLoginBackground> getAll() { return find("select id,image from member_login_background where is_del='N' "); }
使用JsonKit.toJson
List<MemberLoginBackground> rand = MemberLoginBackground.dao.getAll(); String bb = JsonKit.toJson(rand);
然后就卡死了,最终StackOverflowError
Caused by: java.lang.StackOverflowError
at com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor.visit(MySqlOutputVisitor.java:639)
at com.alibaba.druid.sql.ast.expr.SQLCharExpr.accept0(SQLCharExpr.java:43)
at com.alibaba.druid.sql.ast.SQLObjectImpl.accept(SQLObjectImpl.java:41)
at com.alibaba.druid.sql.visitor.SQLASTOutputVisitor.visitorBinaryRight(SQLASTOutputVisitor.java:435)
at com.alibaba.druid.sql.visitor.SQLASTOutputVisitor.visit(SQLASTOutputVisitor.java:396)
at com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr.accept0(SQLBinaryOpExpr.java:98)
at com.alibaba.druid.sql.ast.SQLObjectImpl.accept(SQLObjectImpl.java:41)
at com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor.visit(MySqlOutputVisitor.java:277)
at com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock.accept0(MySqlSelectQueryBlock.java:219)
at com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock.accept0(MySqlSelectQueryBlock.java:210)
at com.alibaba.druid.sql.ast.SQLObjectImpl.accept(SQLObjectImpl.java:41)
at com.alibaba.druid.sql.visitor.SQLASTOutputVisitor.visit(SQLASTOutputVisitor.java:1033)
at com.alibaba.druid.sql.ast.statement.SQLSelect.accept0(SQLSelect.java:87)
at com.alibaba.druid.sql.ast.SQLObjectImpl.accept(SQLObjectImpl.java:41)
at com.alibaba.druid.sql.visitor.SQLASTOutputVisitor.visit(SQLASTOutputVisitor.java:1279)
at com.alibaba.druid.sql.ast.statement.SQLSelectStatement.accept0(SQLSelectStatement.java:63)
at com.alibaba.druid.sql.ast.SQLObjectImpl.accept(SQLObjectImpl.java:41)
at com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils.parameterize(ParameterizedOutputVisitorUtils.java:66)
at com.alibaba.druid.wall.WallProvider.getWhiteSql(WallProvider.java:463)
at com.alibaba.druid.wall.WallProvider.checkWhiteAndBlackList(WallProvider.java:730)
at com.alibaba.druid.wall.WallProvider.checkInternal(WallProvider.java:596)
at com.alibaba.druid.wall.WallProvider.check(WallProvider.java:574)
at com.alibaba.druid.wall.WallFilter.check(WallFilter.java:712)
at com.alibaba.druid.wall.WallFilter.connection_prepareStatement(WallFilter.java:253)
at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:448)
at com.alibaba.druid.filter.FilterAdapter.connection_prepareStatement(FilterAdapter.java:928)
at com.alibaba.druid.filter.FilterEventAdapter.connection_prepareStatement(FilterEventAdapter.java:122)
at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:448)
at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.prepareStatement(ConnectionProxyImpl.java:342)
at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:346)
at com.jfinal.plugin.activerecord.Model.find(Model.java:641)
at com.jfinal.plugin.activerecord.Model.find(Model.java:660)
at com.jfinal.plugin.activerecord.Model.find(Model.java:672)
at com.ibdyr.model.system.MemberLoginBackground.getAll(MemberLoginBackground.java:18)
at com.alibaba.fastjson.serializer.ASMSerializer_1_MemberLoginBackground.write(Unknown Source)
at com.alibaba.fastjson.serializer.ASMSerializer_1_MemberLoginBackground.write(Unknown Source)
at com.alibaba.fastjson.serializer.ASMSerializer_1_MemberLoginBackground.write(Unknown Source)
at com.alibaba.fastjson.serializer.ASMSerializer_1_MemberLoginBackground.write(Unknown Source)
at com.alibaba.fastjson.serializer.ASMSerializer_1_MemberLoginBackground.write(Unknown Source)
at com.alibaba.fastjson.serializer.ASMSerializer_1_MemberLoginBackground.write(Unknown Source)
at com.alibaba.fastjson.serializer.ASMSerializer_1_MemberLoginBackground.write(Unknown Source)
at com.alibaba.fastjson.serializer.ASMSerializer_1_MemberLoginBackground.write(Unknown Source)
at com.alibaba.fastjson.serializer.ASMSerializer_1_MemberLoginBackground.write(Unknown Source)
at com.alibaba.fastjson.serializer.ASMSerializer_1_MemberLoginBackground.write(Unknown Source)
at com.alibaba.fastjson.serializer.ASMSerializer_1_MemberLoginBackground.write(Unknown Source)
at com.alibaba.fastjson.serializer.ASMSerializer_1_MemberLoginBackground.write(Unknown Source)
at com.alibaba.fastjson.serializer.ASMSerializer_1_MemberLoginBackground.write(Unknown Source)
at com.alibaba.fastjson.serializer.ASMSerializer_1_MemberLoginBackground.write(Unknown Source)
at com.alibaba.fastjson.serializer.ASMSerializer_1_MemberLoginBackground.write(Unknown Source)
at com.alibaba.fastjson.serializer.ASMSerializer_1_MemberLoginBackground.write(Unknown Source)
只要记住一点, Model 中禁止写业务代码即可.
还有一点, 问题写在 [反馈] 栏目