**jsp页面代码**
<body>
<div style="padding:8px;height:auto">
参数项名称: <input class="easyui-validatebox" type="text" name="name"
data-options="required:true"> 创建时间: <input
class="easyui-datebox" name="createTime" style="width:80px">
<a href="#" class="easyui-linkbutton" iconCls="icon-search">查找</a> <a
href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'">添加</a>
</div>
<table id="tt" class="easyui-datagrid"></table>
<script type="text/javascript">
$('#tt').datagrid({
title: "用户列表",
width:"100%",
height:550,
iconCls:"icon-save",
rownumbers:false,
pagination:true,
url: 'queryList.action',
pageSize:10,
columns: [
[
{field: "user_code", title: "账号", width:"24%", align: "center"},
{field: "user_account", title: "密码", width:"24%", align: "center"},
{field: "name", title: "姓名", width: "24%", align: "center"},
{field: "names", title: "称呼", width: "24%", align: "center"},
{field:'opt',title:"操作",width:"8%",align:"center",
formatter:function(value,rec){
var btn = "<a class='editcls' onclick='editRow('"+rec.projectname+"','"+rec.projectpackage+"')' href='javascript:void(0)>'编辑</a>";
return btn;
}
}
]
], toolbar: [{
text: '添加',
iconCls: 'icon-add',
handler: function() {
openDialog("add_dialog","add");
}
}, '-', {
text: '修改',
iconCls: 'icon-edit',
handler: function() {
openDialog("add_dialog","edit");
}
}, '-',{
text: '删除',
iconCls: 'icon-remove',
handler: function(){
delAppInfo();
}
}]
});
//设置分页控件
var p = $('#tt').datagrid('getPager');
p.pagination({
pageSize: 5,//每页显示的记录条数,默认为10
pageList: [5, 10, 15],//可以设置每页记录条数的列表
beforePageText: '第',//页数文本框前显示的汉字
afterPageText: '页 共 {pages} 页',
displayMsg: '当前显示 {from} - {to} 条记录 共 {total} 条记录'
});
</script>
</body>
**后台代码**
controller
@RequestMapping(value = "queryList", method = { RequestMethod.POST,
RequestMethod.GET })
public void getAllParam(HttpServletRequest request, HttpServletResponse response,
@RequestParam(required = false, defaultValue = "1") Integer page, //第几页
@RequestParam(required = false, defaultValue = "10") Integer rows, //页数大小
@RequestParam(required = false, defaultValue = "") String paramName,
@RequestParam(required = false, defaultValue = "") String createTime
) throws IOException {
Map<String,Object> map=new HashMap<String,Object>();
map.put("pageSize", rows);
map.put("pageIndex",(page-1)*rows);
try {
List<Uase> list= uaseService.queryList(map);
int totl=uaseService.count();
//设置页面数据
Map<String,Object> jsonMap = new HashMap<String,Object>();
jsonMap.put("total",totl);
jsonMap.put("rows", list);
String jsonStr = JSONObject.toJSONString(jsonMap);
System.out.println(jsonStr);
sendJsonData(response,jsonStr);
} catch (Exception e) {
e.printStackTrace();
}
}
private void sendJsonData(HttpServletResponse response, String data)
throws IOException {
// HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/html;charset=UTF-8");
System.out.println(data);
PrintWriter out;
out = response.getWriter();
out.println(data);
out.flush();
out.close();
}
__** 前端就是没有数据显示**__
这是转换后字符串型的josn数据
{"rows":[{"already_invoiceMoney":0},{"already_invoiceMoney":0},{"already_invoiceMoney":0}],"total":64}
field的字段名要与json数据的字段名对应
不要一次性写那么多字段,你就写一个字段看出的来不
easyui框架正确导入没有,页头显示出来了吗?要先导入jquery再导入easyui,循序不能错
自己f12打开浏览器开发工具看js是否报错
看后台值获取了没,再看传到前台没,如果传到了没有,看jar包导的对不,字段名是否对的上。