前台:
<table id="dg" title="My Users" class="easyui-datagrid" style="width:550px;height:250px"
url="regist.do"
toolbar="#toolbar"
rownumbers="true" fitColumns="true" singleSelect="true">
<thead>
<tr>
<th field="username" 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>
后台
@RequestMapping(value = "regist", method = RequestMethod.POST)
public Object regist(HttpServletRequest request, User user) throws Exception {
List<User> userList= userService.getUsers();
System.out.println(userList);
Map<String, Object> result = new HashMap<String, Object>(2) ;
JSONArray arr = new JSONArray();
JSONObject obj = new JSONObject();
for(int i =0;i<userList.size();i++){
obj.put("username", userList.get(i).getUsername());
arr.add(obj);
}
result.put("total",userList.size() );
result.put("rows", arr);
return JSONObject.fromObject(result);
}
debugger跳进regist方法里了 但是浏览器报jquery-1.7.2.min.js:4 POST http://localhost:8080/SpringMVC/regist.do
没找到这个方法??在问一下spring怎么返回才能把数据加载到表格里