jquery easyui 結合jsp簡單展現(xiàn)table數(shù)據(jù)示例
更新時間:2014年04月18日 15:01:15 作者:
這篇文章主要介紹了jquery easyui 結合jsp簡單展現(xiàn)table數(shù)據(jù),需要的朋友可以參考下
復制代碼 代碼如下:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://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" "http://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>
效果:

相關文章
jQuery中[attribute!=value]選擇器用法實例
這篇文章主要介紹了jQuery中[attribute!=value]選擇器用法,實例分析了[attribute!=value]選擇器匹配不包含指定屬性元素的使用技巧,具有一定的參考借鑒價值,需要的朋友可以參考下2014-12-12Jquery中的$.each獲取各種返回類型數(shù)據(jù)的使用方法
each()方法能使DOM循環(huán)結構簡潔,不容易出錯。each()函數(shù)封裝了十分強大的遍歷功能,使用也很方便,它可以遍歷一維數(shù)組、多維數(shù)組、DOM, JSON 等等,在javaScript開發(fā)過程中使用$each可以大大的減輕我們的工作量。2015-05-05jQuery中attr()和prop()在修改checked屬性時的區(qū)別
使用語句$.attr('checked',true),將復選框的屬性改為被選中,在chrome瀏覽器中第一次點擊有效后面就不行了,IE8倒是沒有問題2014-07-07Jquery Ajax Error 調(diào)試錯誤的技巧
jquery在程序開發(fā)ajax應用程序時提高了效率,減少了需要兼容性的問題,當我們在ajax項目中,遇到ajax異步獲取數(shù)據(jù)出錯該怎么解決呢,我們可以通過捕捉error事件來獲取出錯的信息,本文給大家介紹jquery ajax error調(diào)試錯誤的技巧,感興趣的朋友一起學習吧2015-11-11