<div class="codetitle"> <span><a style="CURSOR: pointer" data="95048" class="copybut" id="copybut95048" onclick="doCopy('code95048')"><u>复制代</u></a></span> 代码如下:</div> <div class="codebody" id="code95048"> <br><%@ page language="java" contentType="text/ html; charset=UTF-8" <BR>pageEncoding="UTF-8"%> <BR><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <BR><html> <BR><頭> <BR><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <br><title>ここにタイトルを挿入</title> <br><link rel="stylesheet" type="text/css" href="easyui/主題/default/easyui.css"> <br><link rel="stylesheet" type="text/css" href="easyui/主題/icon.css"> <br><script type="text/javascript" src="easyui/jquery-1.8.0.min.js"></script> <br><script type="text/javascript" src="easyui/jquery.easyui.min.js"></script> <br><br></head> <br> <br><table id="dg" title="マイ ユーザー" class="easyui-datagrid" style="width:500px;height:250px" <BR>url="getUsers.jsp" <BR>toolbar= "#toolbar" rownumbers="true" <BR>fitColumns="true" singleSelect="true"> <br> <br><tr> <br><th field="firstname" width="50">名</th> <br><th field="lastname" width="50">姓</th> <br><th field="phone" width="50">電話</th> <br><th field="email" width="50">Email</th> <br></tr> <br></頭> <br></table> <br><br></body> <br></html> <br> <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="86762" class="copybut" id="copybut86762" onclick="doCopy('code86762')"><u>复制代</u></a></span>代码如下:</div> <div class="codebody" id="code86762"> <br><%@page import ="net.sf.json.JSONArray"%> <BR><%@page import="java.util.*"%> <br><%@page import="org.codehaus.jackson.map.ObjectMapper"%> <br><%@ page language="java" contentType="text/html; charset=UTF-8" <BR>pageEncoding="UTF-8"%> <br><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <BR><html> <BR><頭> <BR><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <br><title>ここにタイトルを挿入</title> <br></head> <br> <br><% <BR>//String json = "{"firstname":"firstname","lastname":"lastname","phone":123456,"email":"281446883@qq.com"} "; <BR>リスト<マップ<文字列,文字列>> list = new ArrayList<Map<String,String>>(); <BR>マップ<String,String> user1 = 新しい HashMap<String,String>(); <BR>user1.put("名", "名前1"); <BR>user1.put("姓", "名前2"); <BR>user1.put("電話", "1234"); <BR>user1.put("電子メール", "281446888@qq.com"); <BR>list.add(user1); <br><br>マップ<文字列,文字列> user2 = 新しい HashMap<String,String>(); <BR>user2.put("名", "名前2"); <BR>user2.put("姓", "名前4"); <BR>user2.put("電話", "1234"); <BR>user2.put("メール", "281446888@qq.com"); <BR>list.add(user2); <br><br>JSONArray jsonArray = JSONArray.fromObject(list); <BR>System.out.println(jsonArray.toString()); <BR>マップ<String,Object> map = new HashMap<String,Object>(); <br>map.put("合計", 1); <br>map.put("rows", jsonArray); <br><br>ObjectMapper objMap = new ObjectMapper(); <br>objMap.writeValue(response.getWriter(), マップ); <br>//System.out.println(json); <br>%> <br></body> <br></html> <br> </div> <br>效果: <br><img src="http://files.jb51.net/file_images/article/201404/201404181501537.gif?20143181526" alt="jquery easyui と jsp を組み合わせてテーブルデータを単純に表示する example_jquery" > </tr> </div>