@JFinal 你好,想跟你请教个问题: 我在把jfinal从1.8升级到2.0后出现一个bug: 以前图省事,返回json,都是先setAttr(),然后renderJson(). 1.8没问题。2.0出现下面错误:
[ERROR]-[Thread: qtp70161541-20]-[com.jfinal.core.ActionHandler.handle()]: /ajaxload/grid/listMyApply-1-12 java.lang.RuntimeException: Class com.jfinal.kit.JsonKit can not access a member of class java.util.Collections$EmptySet with modifiers "public" at com.jfinal.kit.JsonKit.beanToJson(JsonKit.java:294) at com.jfinal.kit.JsonKit.otherToJson(JsonKit.java:261) at com.jfinal.kit.JsonKit.toJson(JsonKit.java:228) at com.jfinal.kit.JsonKit.toKeyValue(JsonKit.java:95) at com.jfinal.kit.JsonKit.mapToJson(JsonKit.java:81) at com.jfinal.kit.JsonKit.beanToJson(JsonKit.java:300) at com.jfinal.kit.JsonKit.otherToJson(JsonKit.java:261) at com.jfinal.kit.JsonKit.toJson(JsonKit.java:228) at com.jfinal.kit.JsonKit.toKeyValue(JsonKit.java:95) at com.jfinal.kit.JsonKit.mapToJson(JsonKit.java:81) at com.jfinal.kit.JsonKit.beanToJson(JsonKit.java:300) at com.jfinal.kit.JsonKit.otherToJson(JsonKit.java:261) at com.jfinal.kit.JsonKit.toJson(JsonKit.java:228) at com.jfinal.kit.JsonKit.toKeyValue(JsonKit.java:95) at com.jfinal.kit.JsonKit.mapToJson(JsonKit.java:81) at com.jfinal.kit.JsonKit.beanToJson(JsonKit.java:300) at com.jfinal.kit.JsonKit.otherToJson(JsonKit.java:261) at com.jfinal.kit.JsonKit.toJson(JsonKit.java:228) at com.jfinal.kit.JsonKit.toKeyValue(JsonKit.java:95) at com.jfinal.kit.JsonKit.mapToJson(JsonKit.java:81) at com.jfinal.kit.JsonKit.toJson(JsonKit.java:221) at com.jfinal.render.JsonRender.buildJsonText(JsonRender.java:168) at com.jfinal.render.JsonRender.render(JsonRender.java:129) at com.jfinal.core.ActionHandler.handle(ActionHandler.java:93) at com.ehr.index.RootPathHandler.handle(RootPathHandler.java:13) at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72) 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.QueuedThreadPool$3.run(QueuedThreadPool.java:543) at java.lang.Thread.run(Thread.java:744) Caused by: java.lang.IllegalAccessException: Class com.jfinal.kit.JsonKit can not access a member of class java.util.Collections$EmptySet with modifiers "public" at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:109) at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:261) at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:253) at java.lang.reflect.Method.invoke(Method.java:599) at com.jfinal.kit.JsonKit.beanToJson(JsonKit.java:291) ... 48 more
///////////////////////////////////////////////////////////////////
如果用 map放值,然后renderJson(Map),1.8跟2.0的都没问题。
被转换的对象之中有个 Collection 对象,JsonKit 暂时不支持这个类的转换,用其它的对象,如 List、Map 这类对象替换一下即可。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。