我可以使用servlet从数据库中检索所有记录,但无法对其执行分页。所有记录都显示在网格上,分页工具栏显示为54条记录中的5条记录,但实际上它显示的是第一页,第二页等所有记录....
我做了一些研究,一些用户提到了在服务器端使用启动和限制参数,直到现在我还没有在任何网站上找到相同的线索/示例。如果没有替代方法可以通过start和limit参数修改服务器端代码,那么请提供一个关于java servlet的示例代码。
还有一件事要说的是oracle 11g中没有启动和限制参数(无视12c),那么我该如何解决这个问题?
Ext.onReady(function ()
{
var itemsPerPage =5;
var store = Ext.create('Ext.data.Store',{
storeId: 'resultsetstore',
autoload: false,
pageSize:itemsPerPage,
fields:
[
{name: 'firstname', id:'firstname'},
{name: 'email', id:'email'},
{name: 'mobileno', id:'mobileno'}
],
proxy:
{
type:'ajax',
enablePaging: true,
url:'./RetrieveRecords'
},
reader:{type:'json',totalProperty: 'total'}
});
store.load();
Ext.create('Ext.grid.Panel',{
store:store,
layout: 'border',
height:300,
renderTo: Ext.getBody(),
columns:
[
{
header: 'Email',
id: 'email',
dataIndex: 'email',
//autoSizeColumn : true,
flex: 1,
editor: {
xtype: 'textarea'
}
},
{
header: 'Action',
id: 'action',
align: 'center',
xtype: 'actioncolumn',
autoSizeColumn: true,
//flex: 1,
sortable: false,
items:
[
{
icon: 'images/icons/cancel.png',
tooltip: 'Delete',
handler: function (grid, rowIndex, colIndex)
{
var rec = grid.getStore().getAt(rowIndex);
var email = rec.get('email');
Ext.Ajax.request(
{
url: './deleteRecords',
params: {email: email},
method: 'GET',
success: function (response)
{
Ext.Msg.alert("successfully deleted" + " " + response.status);
window.location.reload();
},
failure: function (response)
{
Ext.Msg.alert("failed" + response.status);
}
});
}
}
]
}
],
dockedItems:
[
{
xtype: 'pagingtoolbar',
store: store,
dock: 'bottom',
displayInfo: true
}
]
});
});
这是我的服务器端代码(java servlet):
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, Exception
{
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
JSONArray jarray = new JSONArray();
try
{
Connection con = DBConnection.getConnection();
Statement st = con.createStatement();
String query = "select EMAIL,MOBILENO,FIRSTNAME from UP_CLOUD_REGISTRATION";
ResultSet rs = st.executeQuery(query);
while(rs.next())
{
JSONObject json = new JSONObject();
json.put("email",rs.getString("email"));
json.put("mobileno", rs.getString("mobileno"));
json.put("firstname", rs.getString("firstname"));
jarray.add(json);
}
out.println(jarray);
System.out.println(jarray);
}
catch(Exception e)
{
e.printStackTrace();
}
}
答案 0 :(得分:2)
Oracle已经启动并限制,但它以不同的名称给出
我正在修改你的查询..假设你正在开始并从ext js限制到你的servelt 假设你有start = 3且limit是10 select EMAIL,MOBILENO,FIRSTNAME from UP_CLOUD_REGISTRATION where rownum>=start and limit by limit(value from ext js)
select EMAIL,MOBILENO,FIRSTNAME from UP_CLOUD_REGISTRATION where rownum>=3 and limit by 10