Dojo Datagrid不呈现json数据

时间:2013-02-19 22:45:38

标签: json spring-mvc dojo

我有一个基于Spring mvc的应用程序,它返回了我希望在 dojo datagrid 中呈现的产品列表。我使用了 org.springframework.web.servlet.view使用的.ContentNegotiatingViewResolver MappingJackson2JsonView 作为默认视图。

这是我的弹簧视图配置

 <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">  
  <property name="mediaTypes">  
    <map>  
      <entry key="html" value="text/html"/>  
      <entry key="json" value="application/json"/>  
    </map>  
  </property>     
  <property name="defaultViews">  
    <list>  
      <bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView">  
      </bean>  
    </list>  
</property>  
</bean> 

这是我的基本dojo脚本

<script>
    require([
        "dojo/store/JsonRest",
        "dojo/store/Memory",
        "dojo/store/Cache",
        "dojox/grid/DataGrid",
        "dojo/data/ObjectStore",
        /*"dojo/query",*/
        "dojo/domReady!"
    ], function(JsonRest, Memory, Cache, DataGrid, ObjectStore, query){
        var myStore, dataStore, grid;
        myStore = Cache(JsonRest({target:"products.do"}), Memory());
        alert("MyStore : "+JSON.stringify(myStore));
        grid = new DataGrid({
            store: dataStore = new ObjectStore({objectStore: myStore}),
            structure: [
                {name:"Id", field:"id", width: "200px"},
                {name:"Description", field:"description", width: "200px", editable: true},
                {name:"Price", field:"price", width: "200px"},
                {name:"Category", field:"category", width: "200px", editable: true}                     
            ]
        }, "gridDiv"); // make sure you have a target HTML element with this id
        grid.startup();
        alert("DataStore : "+JSON.stringify(dataStore));
    });
</script>

没有javascript错误,但我看到的只是一个空网格。 在使用Firebug进行检查时,我在响应中看到了这一点

enter image description here

所以我的服务器端到前端连接似乎是正确的。我不清楚的是,尽管如此,网格并没有反映任何行。为什么会发生这种情况?我错过了什么或做错了什么?如果需要任何其他相关信息,请告诉我

0 个答案:

没有答案