第一范文网 - 专业文章范例文档资料分享平台

springmvccontroller返回json出错解决

来源:用户分享 时间:2025/5/30 1:48:51 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

springmvccontroller返回json出错解决

1、出错的地方:

@RequestMapping(value = \

@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL) public @ResponseBody

JSONObject query(@RequestParam(\@RequestParam(\

@RequestParam(\@RequestParam(\@RequestParam(\@RequestParam(\@RequestParam(\

@RequestParam(\

LogInfo info = populateQueryParam(startTime, endTime, oid, cid, payChannel, deviceType, phone, pageSize, startIndex);

// 总记录数

Long totalCount = logMoniterService.queryLogInfoCount(info);

if (totalCount == null) { totalCount = 0L; }

List list = logMoniterService.queryLogInfo(info);

JSONObject retData = new JSONObject(); retData.put(\ retData.put(\ retData.put(\

retData.put(\ return retData; }

2、结果报错:

Apache Tomcat/7.0.42 - Error report

HTTP Status 500 - Could not write JSON: Object is null (through reference chain:

net.sf.json.JSONObject["data"]->net.sf.json.JSONArray[0]->net.sf.json.JSONObject["createTime"]->net.sf.json.JSONNull["empty"]); nested exception is

org.codehaus.jackson.map.JsonMappingException: Object is null (through reference chain:

net.sf.json.JSONObject["data"]->net.sf.json.JSONArray[0]->net.sf.json.JSONObject["createTime"]->net.sf.json.JSONNull["empty"])


message Could not write JSON: Object is null (through reference chain: net.sf.json.JSONObject["data"]->net.sf.json.JSONArray[0]->net.sf.json.JSONObject["createTime"]->net.sf.json.JSONNull["empty"]); nested exception is

org.codehaus.jackson.map.JsonMappingException: Object is null (through reference chain:

net.sf.json.JSONObject["data"]->net.sf.json.JSONArray[0]->net.sf.json.JSONObject["createTime"]->net.sf.json.JSONNull["empty"])

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: Object is null (through reference chain: net.sf.json.JSONObject["data"]->net.sf.json.JSONArray[0]->net.sf.json.JSONObject["createTime"]->net.sf.json.JSONNull["empty"]); nested exception is 

org.codehaus.jackson.map.JsonMappingException: Object is null (through reference chain:

net.sf.json.JSONObject["data"]->net.sf.json.JSONArray[0]->net.sf.json.JSONObject["createTime"]->net.sf.json.JSONNull["empty"])

org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.writeInternal(MappingJacksonHttpMessageConverter.java:203) org.springframework.http.converter.AbstractHttpMessageConverter.write(AbstractHttpMessageConverter.java:179)

org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:148)

org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:90)

org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:189)

org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:69)

org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:122)

org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)

org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686) org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)

org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)

org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)

org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)

org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)

javax.servlet.http.HttpServlet.service(HttpServlet.java:647) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)

javax.servlet.http.HttpServlet.service(HttpServlet.java:728) org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)

org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)

org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)

搜索更多关于: springmvccontroller返回json出错解决 的文档
springmvccontroller返回json出错解决.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c0wcdv32v6r0flug9baz8_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top