0

我想在我的列表中显示从 JSP 页面检索到的数据。我不知道该怎么做。这是我的 JSP 页面。也请更正 JSP 页面。

**category_List.jsp**



  %@page import="java.sql.*, java.util.*" %>
<% 
response.setContentType("application/json");

String result = "{\"root\"[{\"category_name\": \"Model number\"}]}";
response.getWriter().print(result);
response.getWriter().flush();
%>

和我的煎茶代码

Ext.define('Sample.view.Blog',{
           extend:'Ext.navigation.View',
           xtype:'bloglist',
           config:{
               title:'Blog',
               iconCls:'star',
               scrollable:true,
               styleHtmlContent: true,
               items:{
                   xtype: 'list',
                   itemTpl: '{category_name}',
                   store:{
                       autoLoad: true,
                       fields: ['category_name'],
                       proxy:{
                           type: 'jsonp',
                           url: 'http://192.168.0.8:8080/new/category_list.jsp',
                           reader:{
                               type: 'json',
                                rootProperty: 'root'
                           }
                       }
                   }   
               }
           }
           });

我无法在列表中显示类别名称。谁能帮帮我吗。谢谢

4

1 回答 1

0

尝试以下方法,看看是否有帮助。

  1. root您的 JSP 文件在该行的节点之后缺少一个 : String result。将该行更改为

    String result = "{\"root:\"[{\"category_name\": \"Model number\"}]}";
    

    目前,您的 JSP 文件未提供正确的 JSON 文档,这就是您在列表中看不到结果的原因。

  2. 确保 JSP 文件提供正确的 JSON 文档。如果文档不是以开头[和结尾,]则应将其添加到上述行的开头和结尾。

  3. 将商店代理更改为:

    proxy:{
       type: 'ajax',
       url: 'http://192.168.0.8:8080/new/category_list.jsp',
       reader:{
           type: 'json',
           rootProperty: 'root'
       }
    }
    
于 2012-04-10T22:33:22.123 回答