我想在我的页面中实现分页。我正在使用struts 2和hibernate.I已经实现了一个小的jqyery分页但我想从数据库中检索数据。我已经搜索但是我找不到匹配的东西我的代码。我想为客户端实现jquery的分页。谢谢!
的index.jsp
<div id="divs">
<s:if test="listData.size() > 0">
<s:iterator value="listData" status="status">
<article <s:if test="#status.odd == true ">odd</s:if><s:else>even</s:else>>
<div>
<header >
<h2 class="data-title">
<s:url id="idUrl" action="data/viewRead"><s:param name="id"><s:property value="id" /></s:param></s:url>
<s:a href="%{idUrl}" style="color: #3071A9"><s:property value="title" /></s:a>
</h2>
<span class="data-user"><s:property value="user.accountName" /></span> | <span class="data-created"><s:property value="created" /></span>
</header>
<p class="read"><s:property value="description" /></p>
</div>
</article>
</s:iterator>
</s:if>
</div>
dataAction.java
public String listThrowException() {
setListThrowException(facade.listData());
}
dataActionImpl.java
@SuppressWarnings("unchecked")
@Override
public List<Data> listData() {
List<Data> list;
Query query;
try {
query = em.createQuery("from Data order by id desc");
query.setFirstResult(0);
query.setMaxResults(30);
list = query.getResultList();
} catch (Exception e) {
logger.error(Logger.EVENT_FAILURE, e.getMessage());
return null;
}finally{
}
return list;
}