日期:2014-05-16  浏览次数:20332 次

json问题:在页面不显示
用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,可以显示数据。
是什么问题?

------解决方案--------------------
页面获取后得自己写显示,要不人家怎么知道你想显示什么
------解决方案--------------------
你先将取得的json , 能用一个循环, document.write出来了, 再说吧
------解决方案--------------------
firebug 调试。看看你获取到是格式是否有问题啊
------解决方案--------------------
firebug 调试。 按楼上的小哥说的试试
------解决方案--------------------
<table id="tt" class="easyui-datagrid"
url="searchBooktoM",
dataType="json",
title="Searching" iconCls="icon-search" toolbar="#tb"
rownumbers="true" pagination="true">

没见过这样获取json的。
得用ajax请求回调来做显示