Copy Code code as follows:
<%@ 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" >
<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>
<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= ">first name</th>"
<th field= "LastName" width= ">last name</th>"
<th field= "Phone" width= "M" >Phone</th>
<th field= "Email" width= ">Email</th>"
</tr>
</thead>
</table>
</body>
Copy Code code as follows:
<% @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" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title>insert title here</title>
<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>
Effect: