2013-03-11 31 views
0

下午好,错误加载JSON KendoUI电网

我做的是整合剑道UI(JSP版)在我的应用程序,但我有与运输对电网阅读的整合问题。

网格可以正常提出请求。

回报:

{} && {"registros": 
     [ 
      { 
      "id":251, 
      "matricula":"32849923", 
      "status":true, 
      "dataAdmissao":1361674800000, 
      "dataDesligamento":null, 
      "version":0 
      } 
     ], 
     "total":1} 

但网格无法呈现数据的回报。下面是我的网格:

<kendo:grid name="grid" pageable="true" sortable="true" filterable="true" height="300"> 
       <kendo:grid-columns> 
        <kendo:grid-column title="Matricula" field="matricula" /> 
       </kendo:grid-columns> 
       <kendo:dataSource pageSize="10" serverPaging="true" serverSorting="true" serverFiltering="true" serverGrouping="true"> 
        <kendo:dataSource-transport>     
         <kendo:dataSource-transport-read url="${path}funcionarios" type="GET" contentType="application/json" dataType="json" />     
        </kendo:dataSource-transport> 
        <kendo:dataSource-schema total="total" data="registros"> 
         <kendo:dataSource-schema-model> 
          <kendo:dataSource-schema-model-fields> 
           <kendo:dataSource-schema-model-field name="matricula" type="string" /> 
          </kendo:dataSource-schema-model-fields> 
         </kendo:dataSource-schema-model> 
        </kendo:dataSource-schema> 
       </kendo:dataSource> 
      </kendo:grid> 
  • 索取资料:

    • 请求
    • 网址:/ qualitysoft/funcionarios取= 10 &跳过= 0 &页面= 1 &的pageSize = 10
    • 请求方法:GET状态码:200 OK请求头文查看源文件
    • 接受:application/json,text/javascript,/; Q = 0.01
    • 接收字符集:UTF-8,*; Q = 0.5的Accept-Encoding:gzip的,放气,SDCH
    • 接受语言:EN-US,EN; Q = 0.8连接:保活
    • 内容类型:应用/ JSON
  • 查询字符串Parametersview sourceview URL编码取:10跳过:0

    • 页面:1
    • 每页:10

回答

1

当你说回报是:

{} && { 
    "registros": [ 
     { 
      "id":    251, 
      "matricula":  "32849923", 
      "status":   true, 
      "dataAdmissao":  1361674800000, 
      "dataDesligamento": null, 
      "version":   0 
     } 
    ], 
    "total":  1 
} 

你的意思是,如果你在浏览器中打开URL,它是你得到了什么?如果是这样,问题是这不是一个有效的JSON检索文件。如果您将其更改为:

{ 
    "registros": [ 
     { 
      "id":    251, 
      "matricula":  "32849923", 
      "status":   true, 
      "dataAdmissao":  1361674800000, 
      "dataDesligamento": null, 
      "version":   0 
     } 
    ], 
    "total":  1 
} 

然后它工作。

+0

我真的也这么想过。我正在设定杰克逊在项目中验证返回。 – 2013-03-11 12:15:05

+0

我使用杰克逊,它工作正常。 – OnaBai 2013-03-11 12:27:51

+0

我检查了所有设置,但显然没关系。我不明白的是他为什么要添加无效字符。看到http://stackoverflow.com/questions/15339190/error-jackson-serialization – 2013-03-11 13:01:08