当前位置: 移动技术网 > IT编程>开发语言>JavaScript > jquery easyui 结合jsp简单展现table数据示例

jquery easyui 结合jsp简单展现table数据示例

2019年04月08日  | 移动技术网IT编程  | 我要评论

jquery easyui 结合简单展现table数据示例代码如下:

<%@ page language="java" contenttype="text/html; charset=utf-8"
pageencoding="utf-8"%>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "https://www.w3.org/tr/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>insert title here</title>
<link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">
<script type="text/javascript" src="easyui/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>

</head>
<body>
<table id="dg" title="my users" class="easyui-datagrid" style="width:500px;height:250px"
url="getusers.jsp"
toolbar="#toolbar" rownumbers="true"
fitcolumns="true" singleselect="true">
<thead>
<tr>
<th field="firstname" width="50">first name</th>
<th field="lastname" width="50">last name</th>
<th field="phone" width="50">phone</th>
<th field="email" width="50">email</th>
</tr>
</thead>
</table>

</body>
</html>


. 代码如下:


<%@page import="net.sf.json.jsonarray"%>
<%@page import="java.util.*"%>
<%@page import="org.codehaus.jackson.map.objectmapper"%>
<%@ page language="java" contenttype="text/html; charset=utf-8"
pageencoding="utf-8"%>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "https://www.w3.org/tr/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>insert title here</title>
</head>
<body>
<%
//string json = "{\"firstname\":\"firstname\",\"lastname\":\"lastname\",\"phone\":123456,\"email\":\"281446883@qq.com\"}";
list<map<string,string>> list = new arraylist<map<string,string>>();
map<string,string> user1 = new hashmap<string,string>();
user1.put("firstname", "name1");
user1.put("lastname", "name2");
user1.put("phone", "1234");
user1.put("email", "281446888@qq.com");
list.add(user1);

map<string,string> user2 = new hashmap<string,string>();
user2.put("firstname", "name2");
user2.put("lastname", "name4");
user2.put("phone", "1234");
user2.put("email", "281446888@qq.com");
list.add(user2);

jsonarray jsonarray = jsonarray.fromobject(list);
system.out.println(jsonarray.tostring());
map<string,object> map = new hashmap<string,object>();
map.put("total", 1);
map.put("rows", jsonarray);

objectmapper objmap = new objectmapper();
objmap.writevalue(response.getwriter(), map);
//system.out.println(json);
%>
</body>
</html>


效果:
\

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网