我试图找出代码来使用json从我的jsp文件中发送数据,就像这样
<%@ page buffer="none" session="false" trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.lang.*"%>
<%@ page import="java.sql.*,java.util.*,java.io.*,java.text.SimpleDateFormat,org.apache.commons.fileupload.servlet.ServletFileUpload,org.apache.commons.fileupload.disk.DiskFileItemFactory,org.apache.commons.fileupload.*"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="UTF-8" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" import="org.json.JSONArray,org.json.JSONException"%>
<%@ page import="org.json.simple.JSONObject"%>
<%@ page import="java.util.Date"%>
<%
ArrayList<String> list = new ArrayList<String>();
JSONArray arrayObj = new JSONArray();
JSONArray data = new JSONArray();
int count = 0;
JSONObject json = new JSONObject();
try{
Connection conn = null;
Class.forName("org.postgresql.Driver").newInstance();
conn = DriverManager.getConnection(
"jdbc:postgresql://10.226.1.10:5444/nvsdemo","nvsweb", "nvsweb");
Statement stmt = conn.createStatement();
PreparedStatement ps=conn.prepareStatement("select * from school_facility_detail");
ResultSet rs = ps.executeQuery();
while(rs.next())
{
count++;
json.put("title",rs.getString("title"));
json.put("title_hindi",rs.getString("title_hindi"));
json.put("description_hindi",rs.getString("description_hindi"));
json.put("description",rs.getString("description"));
json.put("release_date",rs.getString("release_date"));
json.put("validity_date",rs.getString("validity_date"));
json.put("facility_id",rs.getString("facility_id"));
data.put(json);
//break;
//out.println(arrayObj);
//out.println(",");
}
}
catch(Exception e){
out.println(e);
}
out.print(data);
out.flush();
%>
我尝试通过此
显示数据<script>
$.ajax({
url : '/nvs/system/modules/NVS.School/elements/facilities_edit.jsp',
data: { },
success : function(data) {
$.each(JSON.parse(data), function(index, item){
var row = create_seller_table_row(item);
$('table tbody').append(row);
});
$('table').trigger('footable_initialize');
},
error : function(xhr, statusText, error) {
alert("Error! Could not retrieve the data.");
}
});
</script>
在我的表格中
<table id="hello" class='table table-bordered'>
<thead>
<tr><th>Title-English </th>
<th>Title-Hindi</th>
<th>Description-English</th>
<th>Description-Hindi </th>
<th>Release-Date</th>
<th>Validity-Date</th>
<th>Facility</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
但是我无法实现分页,在此我知道原始代码是
jQuery(function($){
$('.table').footable({
"columns": $.get('columns.json'),
"rows": $.get('rows.json')
});
});
使用json文件获取数据,但我无法重现相同,任何想法如何为这个footable实现分页和编辑器选项