easyui datagrid struts2 为什么不显示数据
----JS----$(function(){$('#dg').datagrid({title:'天啊',fitColumns:true,url:'dl_summary....
----JS----
$(function(){
$('#dg').datagrid({
title:'天啊',
fitColumns:true,
url:'dl_summary.action',
columns:[[
{field:'code',title:'号码',width:100},
{field:'name',title:'名字',width:100},
{field:'price',title:'价格',width:100,align:'right'}
]]
});
----ACTION-----
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONObject;
import com.opensymphony.xwork2.ActionSupport;
import com.wxq.model.Demo;
public class Action extends ActionSupport{
private static final long serialVersionUID = 1L;
private JSONObject dg;
private Demo demo;
private String code;
private String name;
private String price;
private String rows;
private String total;
public String summary(){
//this.setCode("222");
this.setName("333");
this.setPrice("444");
this.setTotal("{\"code\":\"555\",\"name\":\"666\",\"price\":\"777\"}");
demo = new Demo();
demo.setCode("555");
demo.setName("666");
demo.setPrice("777");
//this.setJo(JSONObject.fromObject(demo));
List<Demo> ld = new ArrayList<Demo>();
ld.add(demo);
Map<String,Object> map = new HashMap<String,Object>();
map.put("total", "1");
map.put("rows", ld);
this.setDg(JSONObject.fromObject(map));
System.out.println(dg+code);
return "summary";
}
页面可以获取到数据 还有JSONObject 但datagrid不显示数据 请问原因在哪 展开
$(function(){
$('#dg').datagrid({
title:'天啊',
fitColumns:true,
url:'dl_summary.action',
columns:[[
{field:'code',title:'号码',width:100},
{field:'name',title:'名字',width:100},
{field:'price',title:'价格',width:100,align:'right'}
]]
});
----ACTION-----
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONObject;
import com.opensymphony.xwork2.ActionSupport;
import com.wxq.model.Demo;
public class Action extends ActionSupport{
private static final long serialVersionUID = 1L;
private JSONObject dg;
private Demo demo;
private String code;
private String name;
private String price;
private String rows;
private String total;
public String summary(){
//this.setCode("222");
this.setName("333");
this.setPrice("444");
this.setTotal("{\"code\":\"555\",\"name\":\"666\",\"price\":\"777\"}");
demo = new Demo();
demo.setCode("555");
demo.setName("666");
demo.setPrice("777");
//this.setJo(JSONObject.fromObject(demo));
List<Demo> ld = new ArrayList<Demo>();
ld.add(demo);
Map<String,Object> map = new HashMap<String,Object>();
map.put("total", "1");
map.put("rows", ld);
this.setDg(JSONObject.fromObject(map));
System.out.println(dg+code);
return "summary";
}
页面可以获取到数据 还有JSONObject 但datagrid不显示数据 请问原因在哪 展开
2个回答
展开全部
我个人建议试试我郑塌薯的代码
你把最后的return "衫岁summary" 换成
HttpServletResponse response = servletActionContext.getResponse();
PrintWriter out = response.getWriter();
out.print( JSONObject.fromObject(map) );
return null;
我个人觉得datagrid是一种异步请求,需要控制器直接返回一个喊者json数据给datagrid
你把最后的return "衫岁summary" 换成
HttpServletResponse response = servletActionContext.getResponse();
PrintWriter out = response.getWriter();
out.print( JSONObject.fromObject(map) );
return null;
我个人觉得datagrid是一种异步请求,需要控制器直接返回一个喊者json数据给datagrid
追问
我又做了个 直接返回 String 和JSONObject的都不行啊
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询