jquery easyui 結(jié)合jsp簡(jiǎn)單展現(xiàn)table數(shù)據(jù)示例
更新時(shí)間:2014年04月18日 15:01:15 作者:
這篇文章主要介紹了jquery easyui 結(jié)合jsp簡(jiǎn)單展現(xiàn)table數(shù)據(jù),需要的朋友可以參考下
復(fù)制代碼 代碼如下:
<%@ 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>
復(fù)制代碼 代碼如下:
<%@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>
效果:

相關(guān)文章
jQuery中[attribute!=value]選擇器用法實(shí)例
這篇文章主要介紹了jQuery中[attribute!=value]選擇器用法,實(shí)例分析了[attribute!=value]選擇器匹配不包含指定屬性元素的使用技巧,具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2014-12-12bootstrap+jquery項(xiàng)目引入文件報(bào)錯(cuò)的解決方法
這篇文章主要介紹了bootstrap+jquery項(xiàng)目引入文件的常見(jiàn)報(bào)錯(cuò)問(wèn)題,下面小編給大家?guī)?lái)了一些錯(cuò)誤及錯(cuò)誤的解決方法,需要的朋友可以參考下2018-01-01Jquery中的$.each獲取各種返回類(lèi)型數(shù)據(jù)的使用方法
each()方法能使DOM循環(huán)結(jié)構(gòu)簡(jiǎn)潔,不容易出錯(cuò)。each()函數(shù)封裝了十分強(qiáng)大的遍歷功能,使用也很方便,它可以遍歷一維數(shù)組、多維數(shù)組、DOM, JSON 等等,在javaScript開(kāi)發(fā)過(guò)程中使用$each可以大大的減輕我們的工作量。2015-05-05jQuery學(xué)習(xí)2 選擇器的使用說(shuō)明
利用選擇器,選擇要被操作的html中的元素。2010-02-02jQuery實(shí)現(xiàn)的事件綁定功能基本示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)的事件綁定功能,結(jié)合簡(jiǎn)單表單驗(yàn)證實(shí)例分析了jQuery事件綁定的實(shí)現(xiàn)與使用方法,需要的朋友可以參考下2017-10-10$.format,jquery.format 使用說(shuō)明
$.format,jquery.format 使用說(shuō)明,需要的朋友可以參考下。2011-07-07jQuery中attr()和prop()在修改checked屬性時(shí)的區(qū)別
使用語(yǔ)句$.attr('checked',true),將復(fù)選框的屬性改為被選中,在chrome瀏覽器中第一次點(diǎn)擊有效后面就不行了,IE8倒是沒(méi)有問(wèn)題2014-07-07Jquery Ajax Error 調(diào)試錯(cuò)誤的技巧
jquery在程序開(kāi)發(fā)ajax應(yīng)用程序時(shí)提高了效率,減少了需要兼容性的問(wèn)題,當(dāng)我們?cè)赼jax項(xiàng)目中,遇到ajax異步獲取數(shù)據(jù)出錯(cuò)該怎么解決呢,我們可以通過(guò)捕捉error事件來(lái)獲取出錯(cuò)的信息,本文給大家介紹jquery ajax error調(diào)試錯(cuò)誤的技巧,感興趣的朋友一起學(xué)習(xí)吧2015-11-11