zoukankan      html  css  js  c++  java
  • org.json.JSONObject and no properties discovered 错误解决

    自己在搭建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("请求发送失败")
                }
                
      })
  • 相关阅读:
    [树形DP]Luogu P1131 [ZJOI2007]时态同步
    [状压DP]JZOJ 1303 骑士
    [DFS]JZOJ 1301 treecut
    [最小费用最大流]JZOJ 4802 探险计划
    [KMP][倍增求LCA]JZOJ 4669 弄提纲
    [DP]JZOJ 1758 过河
    列表生成式和生成器表达式
    协程函数
    生成器
    迭代器
  • 原文地址:https://www.cnblogs.com/ChromeT/p/9961047.html
Copyright © 2011-2022 走看看