@JFinal 你好,想跟你请教个问题:
jFinal的renderJson使用gson的JsonObject或JsonArray对象会报错
java.lang.RuntimeException at com.jfinal.kit.JsonKit.beanToJson(JsonKit.java:255) at com.jfinal.kit.JsonKit.otherToJson(JsonKit.java:237) at com.jfinal.kit.JsonKit.toJson(JsonKit.java:205) at com.jfinal.render.JsonRender.<init>(JsonRender.java:84) at com.jfinal.render.RenderFactory.getJsonRender(RenderFactory.java:159) at com.jfinal.core.Controller.renderJson(Controller.java:901) at zyl.justaa.site.controller.UserController.list(UserController.java:105) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:55) at zyl.justaa.site.interceptor.GlobalInterceptor.intercept(GlobalInterceptor.java:11) at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:51) at com.jfinal.core.ActionHandler.handle(ActionHandler.java:73) at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:680) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.jfinal.kit.JsonKit.beanToJson(JsonKit.java:252) ... 31 more Caused by: java.lang.IllegalStateException at com.google.gson.JsonArray.getAsString(JsonArray.java:133) ... 36 more
gson这类工具类转json一般都只针对传统javabean,而非jfinalModel,所以建议先使用jfinal自带的JsonKit来做,如果一定要用第三方,看可不可以扩展一下使用其支持jfinalmodel<divclass="ref">
请教<aclass='referer'target='_blank'>@JFinal波大,如果希望输出json时,以这种形式,例如:blog/outputJson?id=1
id为参数怎么实现?
看到你:<arel="nofollow">http://www.oschina.net/question/812908_72711,很受用,谢谢
<divclass="ref">版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。