日期:2014-05-16 浏览次数:20483 次
@SuppressWarnings("unchecked") public String getChargeMode(){ //根据产品id 获取计费方式 String productid ="402881833492ec97013492f512870003"; List<ChargeMode> vmchargeList = chargeModeService.findByProductId(productid); //New个 Gson对象 Gson gson = new Gson(); //直接toJson 真是Gson的强大之处 String result = gson.toJson(vmchargeList); System.out.println(result); //基类定义的 返回形式 return ajaxText(result); }
private String id; //transient这个关键字是过滤不必要的底层信息 transient private Product product; private String chargeName; private String timeType; private String unit;
jQuery.ajax({ dataType: "json", type: "post", url: "<%=basePath%>product!getChargeMode.action", success: function(data) { jQuery.each(data, function(i, field){ //遍历所有记录, alert所有的id alert(field['id']); }); } });
[{"id":"40288036379bd5b101379bd6455e0001","chargeName":"包月","timeType":"M","unit":"元/月"}