반응형
1. javascript
$("#list").jqGrid({
url: g_url,
// data: "table=users",
postData: {table: 'users'}, /** 중요 **/
// cache: false,
// global: false, /** trigger global Ajax event handlers for this request **/
// async: false,
mtype:"POST",
datatype: 'json',
// contentType: "application/x-www-form-urlencoded",
colNames: ['ID', '이름', '권한', '이메일'],
colModel: [
{name:'id', index:'id', width:55},
{name:'name', index:'name', width:90},
{name:'auth', index:'auth', width:90},
{name:'email', index:'email', width:90}
],
rowNum: 10,
rowList: [10,20,30],
pager: 'pager',
sortname: 'id',
viewrecords: true
// sortorder: 'desc',
// caption: 'json Excample'
}).jqGrid('navGrid', '#pager', {edit: false, add: false, del: false});
2. response class ( VO )
public class UserResponse {
private List<User> rows;
private Integer total;
private Integer records;
private Integer page;
public List<User> getRows() {
return rows;
}
public void setRows(List<User> rows) {
this.rows = rows;
}
public Integer getTotal() {
return total;
}
public void setTotal(Integer total) {
this.total = total;
}
public Integer getRecords() {
return records;
}
public void setRecords(Integer records) {
this.records = records;
}
public Integer getPage() {
return page;
}
public void setPage(Integer page) {
this.page = page;
}
}
3. controller
@RequestMapping(value="/list.do", method=RequestMethod.POST, produces={"application/xml", "application/json"})
public @ResponseBody UserResponse list(@RequestParam Map<String, String> table, @RequestParam int page, @RequestParam int rows, @RequestParam String sidx, @RequestParam String sord) throws Exception {
UtilMap utilMap = new UtilMap(table);
UtilMap listParam = setListParam(utilMap, page, rows);
UserResponse response = new UserResponse();
response.setRows(userService.getUserList(listParam));
response.setTotal(listParam.getInt("total_pages"));
response.setRecords(listParam.getInt("count"));
response.setPage(listParam.getInt("page"));
return response;
}
728x90
반응형
'웹 개발' 카테고리의 다른 글
[java] 문자열 더하기 (0) | 2019.08.23 |
---|---|
HTML 객체의 넓이보다 text의 길이가 길어졌을 경우 ... 처리 방법 (ellipsis) (0) | 2019.08.23 |
java class 내에서 this와 this()의 차이 (0) | 2019.08.23 |
[javascript] insert item into array at a specific index (원하는 위치에 값 추가) (0) | 2019.08.23 |
JBAS018014 META-INF/valang.tld 에러 (0) | 2019.08.23 |