用jquery easyui 做的。 现在的问题是json数据在页面上不显示。后台用Struts已经转换为json了
PrintWriter out=ServletActionContext.getResponse().getWriter();
ServletActionContext.getResponse().setContentType("Content-type:text/xml;charset=UTF-8");
out.print(listJson);
out.flush();
前台获取json:
<table id="tt" class="easyui-datagrid" 
url="searchBooktoM",
dataType="json",
title="Searching" iconCls="icon-search" toolbar="#tb"
rownumbers="true" pagination="true">
<thead>
<tr>
   <th field="bookIndex" width="80">索书号</th>
<th field="bookName" width="80">书名</th>
<th field="bookAuthor" width="120">作者</th>
<th field="bookPress" width="80" align="right">出版社</th>
<th field="bookPrice" width="80" align="right">价格</th>
<th field="" width="60" align="center">操作</th>
</tr>
</thead>
</table>
如果把后台打印的json数据存为*.json文件,前台的url指向json,可以显示数据。
是什么问题?

解决方案 »

  1.   

    不需要展示来展示去, 你要先看你取得的json, 是否是真正的json. 
    一般后台取的json, 都是string, 要
    var json=eval(str); //转一次的
      

  2.   

    你先将取得的json , 能用一个循环, document.write出来了, 再说吧
      

  3.   

    firebug 调试。看看你获取到是格式是否有问题啊
      

  4.   

    firebug 调试。  按楼上的小哥说的试试
      

  5.   

    <table id="tt" class="easyui-datagrid"  
    url="searchBooktoM",
    dataType="json",
    title="Searching" iconCls="icon-search" toolbar="#tb"
    rownumbers="true" pagination="true">没见过这样获取json的。
    得用ajax请求回调来做显示