日期:2014-05-18 浏览次数:20873 次
public String list() {
try {
List<UserBean> ulist = userService.getAllUser();
Map<String, Object> map=new HashMap<String, Object>();
map.put("total",new Integer(ulist.size()));
map.put("rows",ulist);
JSONArray json = JSONArray.fromObject(map);
dataString = json.toString();
dataString = dataString.substring(1, dataString.length()-1);
log.info("dataString: "+dataString);
return SUCCESS;
} catch (Exception e) {
log.error("----------error----------", e);
return "error";
}
}
<action name="listUser" class="com.myssh.demo.action.UserAction" method="list">
<result name="success" type="json" >
<param name="root">dataString</param>
</result>
<result name="error">/WEB-INF/jsp/error.jsp</result>
</action>
<table id="mydatagrid" class="easyui-datagrid" title="DataGrid Complex Toolbar" style="width:700px;height:250px"
data-options="rownumbers:true,singleSelect:true,url:'<c:url value="userinfo/listUser"/>',
method:'get',toolbar:'#tb',loadFilter: function(data){ alert(data); }">
<thead>
<tr>
<th data-options="field:'id',width:80">id</th>
<th data-options="field:'name',width:100">name</th>
<th data-options="field:'password',width:80,align:'right'">password</th>
</tr>
</thead>
</table>