分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

org.json.JSONObject and no properties discovered 错误解决

发布时间:2023-09-06 02:22责任编辑:彭小芳关键词:jsjson

自己在搭建SSM框架的时候(Spring + spring mvc + mybatis)报错内容如下:

No serializer found for class org.json.JSONObject and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)

报错的意思是用的这个JSONObject对象由于没有实例化引起的 !!

导包注意点!(版本随意 但是包要导正确)

commons-beanutils-1.7.0.jar

commons-collections-3.2.1.jar

commons-lang-2.4.jar

commons-logging-1.1.3.jar

ezmorph-1.0.3.jar

json-lib-2.2.3-jdk15.jar

JSONArray 和 JSONObject 分别是位于以下

import net.sf.json.JSONArray;import net.sf.json.JSONObject;

后端代码返回

  @ResponseBody ???@RequestMapping(method = RequestMethod.POST, value = "/loadItems") ???public JSONArray loadItems(HttpServletRequest request) { ???????int index = Integer.valueOf(request.getParameter("index")); ???????JSONArray json = itemService.loadItemsByIndex(index); ???????System.out.println(json); ???????return json;     //返回jsonarray数据 ???}

前台AJAX Success函数接收

$.ajax({ ???????????type:"post", ???????????url:"loadItems", ???????????async:"false", ???????????data:{ ???????????????index:1 ???????????}, ???????????dataType:"json", ???????????success:function(data){ ???????????????alert(data); ???????????}, ???????????error:function(request) { ???????????????alert("请求发送失败") ???????????} ?????????????})

org.json.JSONObject and no properties discovered 错误解决

原文地址:https://www.cnblogs.com/ChromeT/p/9961047.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved