renderJson()出错

jkluooop 发布于 2015/07/22 15:54
阅读 1K+
收藏 0

@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的都没问题。

以下是问题补充:

@jkluooop:找到了。是因为我加了国际化出现的。 //me.add(new I18nInterceptor()); 加了国际化全局拦截器后,就不能用setAttr()->renderJson()了 (2015/07/22 15:59)
加载中
0
JFinal
JFinal
   被转换的对象之中有个  Collection 对象,JsonKit 暂时不支持这个类的转换,用其它的对象,如 List、Map 这类对象替换一下即可。
返回顶部
顶部