我正在尝试在我的jtable中显示数据,但它只是显示了我的表中的行数而不是数据。 我的jsp看起来像
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>jtable integration</title>
<%-- JQuery --%>
<script src="<c:url value="/js/jquery-1.8.2.js" />"></script>
<script src="<c:url value="/js/jquery-ui-1.10.4.custom.js" />"></script>
<%-- Jtable --%>
<script src="<c:url value="/js/Utility.js" />"></script>
<script src="<c:url value="/js/jTable/jquery.jtable.js" />"></script>
<script src="<c:url value="/js/jTable/jquery.jtable.min.js" />"></script>
<script src="<c:url value="/js/StudentJtable.js" />"></script>
<link href="<c:url value="/css/jquery-ui-1.10.4.custom.css" />"
rel="stylesheet">
<link href="<c:url value="/js/jTable/Themes/Metro/blue/jtable.css" />"
rel="stylesheet">
</head>
<body>
<h1>hi</h1>
<div>
<div id="StudentTableContainer" style="width: 99%;"></div>
</div>
<button onclick="myFunction()"></button>
<label id="test">tttt</label>
</body>
</html>
studenttable.js
$(document).ready(function() {
//setup the jtable that will display the results
$('#StudentTableContainer').jtable({
title: 'Table of Student',
selecting: true, //Enable selecting
paging: true, //Enable paging
pageSize: 10, //Set page size (default: 10)
sorting: true, //Enable sorting
actions: {
listAction: 'datatable/getAllStudents',
},
fields: {
ID: {
title: 'iD',
key: true,
list: true,
create: false,
edit: false
},
NAME: {
title: 'name',
width: '50%'
},
AGE: {
title: 'age',
width: '30%'
}
}
});
$('#StudentTableContainer').jtable('load');
});
学生模特
package com.model;
import java.util.Date;
public class Student {
private Integer age;
private String name;
private Integer id;
public void setAge(Integer age) {
this.age = age;
}
public Integer getAge() {
return age;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
}
控制器
@RequestMapping(value = "datatable/getAllStudents", method = RequestMethod.POST, produces="application/json")
@ResponseBody
public JsonJtableStudentListResponse getAllExpenses(@RequestParam int jtStartIndex, @RequestParam int jtPageSize) {
JsonJtableStudentListResponse jstr;
int count= 0;
List<Student> students= studentDaoImp.getStudents();
count=students .size();
jstr = new JsonJtableStudentListResponse("OK",students,count);
return jstr;
//return new JsonJtableResponse().ok(students);
}
表中共有9条记录,而我的jtable显示9行,但没有数据。
有人可以帮助我,我现在正在学习这个。 提前谢谢。
答案 0 :(得分:0)
抱歉,我犯了一个最愚蠢的错误。
$(document).ready(function() {
//setup the jtable that will display the results
$('#StudentTableContainer').jtable({
title: 'Table of Student',
selecting: true, //Enable selecting
paging: true, //Enable paging
pageSize: 10, //Set page size (default: 10)
sorting: true, //Enable sorting
actions: {
listAction: 'datatable/getAllStudents',
},
fields: {
ID: {
title: 'iD',
key: true,
list: true,
create: false,
edit: false
},
NAME: {
title: 'name',
width: '50%'
},
AGE: {
title: 'age',
width: '30%'
}
}
});
$('#StudentTableContainer').jtable('load');
});
我在我的js中使用大写字母,在我的模型表中使用小号。