标签:
1,公共函数,表单数据转JSON
//将表单数据转为json
function form2Json(id) {
var arr = $("#" + id).serializeArray()
var jsonStr = "";
jsonStr += ‘{‘;
for (var i = 0; i < arr.length; i++) {
jsonStr += ‘"‘ + arr[i].name + ‘":"‘ + arr[i].value + ‘",‘
}
jsonStr = jsonStr.substring(0, (jsonStr.length - 1));
jsonStr += ‘}‘
console.log("jsonStr : " + jsonStr);
var json = JSON.parse(jsonStr)
return json
}
function findData() {
$(‘#grid‘).datagrid({
queryParams: form2Json("searchForm")
}); // 点击搜索
}
/**
*
* 方法说明:套餐分页查询
*
* Author: Jing Create Date: 2015年6月12日 下午3:24:52
*
* @param user
* @param page
* @param rows
* @return
* @throws Exception
*
*/
@RequestMapping("/queryPackageIndex")
@ResponseBody
public JSONObject mgrList(FarmPackage farmPackage, Integer page,
Integer rows) throws Exception {
page = (Integer) ((page == null || page == 0) ? "1" : page);
rows = (Integer) ((rows == null || rows == 0) ? "20" : rows);
GridResult<FarmPackage> grid = farmPackageService.queryFarmPackage(
page, rows, farmPackage);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(grid);
return jsonObject;
}
标签:
原文地址:http://blog.csdn.net/mergades/article/details/46543973