这是前台的js:
$.ajax({
"type": "GET",
"url": "/itemsqry.action",
"data": {"report_no":$("#huoquselcet").val()},
"dataType": "json",
"success": function(data){
$('#itemcellselect').empty(); //清空resText里面的所有内容
var html = "";
$.each(data, function(index, value){
html = "" + value.item_name +"";
$('#itemcellselect').append(html);
});
},
"error":function(){
alert("网络错误!");
}
});
这是struts.xml:
entities
#
这是struts的action:
public String itemsqry(String report_no){
System.out.println(report_no);
items.setReport_no(report_no);
this.itemsList = reportBiz.getItems(items);
if (itemsList == null) {
return null;
}
JSONArray array = new JSONArray(); //数组
JSONObject jsOb = new JSONObject();; //json对象
JSONObject jsonObject = null; //json对象
Items info = null;
for (int i = 0; i < itemsList.size(); i++) {
info = itemsList.get(i);
jsonObject = new JSONObject();
jsonObject.put("report_no", info.getReport_no());
jsonObject.put("item_cell", info.getItem_cell());
jsonObject.put("item_name", info.getItem_name());
jsonObject.put("item_type", info.getItem_type());
array.add(jsonObject);
}
jsOb.put("data", array);
return jsOb.toString();
}