日期:2014-05-18 浏览次数:20718 次
<struts>
<package name="notice" namespace="/notice" extends="hrm">
<!-- 按条件分页查询公告 -->
<action name="selectNotice" class="com.bing.hrm.action.notice.NoticeAction" method="selectNotice">
<result name="success">/WEB-INF/jsp/notice/notice.jsp</result>
</action>
</package>
</struts>
public class NoticeAction extends AbstractAction {
private static final long serialVersionUID = -4047001258498002589L;
/** 查询条件 */
private Notice notice;
/** 分页的结果 */
private List<Notice> notices;
/** 定义分页实体 */
private PageModel pageModel = new PageModel();
/** 按条件分页查询公告 */
public String selectNotice() {
try{
notices = hrmService.getNoticeByPage(notice, pageModel);
}catch(Exception ex){
log(ex);
ex.printStackTrace();
}
return SUCCESS;
}
/** setter and getter method */
public Notice getNotice() {
return notice;
}
public void setNotice(Notice notice) {
this.notice = notice;
}
public List<Notice> getNotices() {
return notices;
}
public void setNotices(List<Notice> notices) {
this.notices = notices;
}
public PageModel getPageModel() {
return pageModel;
}
public void setPageModel(PageModel pageModel) {
this.pageModel = pageModel;
}
}
public class PageModel {
/** 默认每页显示的记录条数 */
private static final int PAGE_SIZE = 2;
/** 当前页码 */
private int pageIndex;
/** 每页显示的数量 */
private int pageSize;
/** 总记录条数 */
private int recordCount;
/** setter and getter method */
public int getPageIndex() {
return pageIndex < 1 ? 1 : pageIndex;
}
public void setPageIndex(int pageIndex) {
this.pageIndex = pageIndex;
}
public int getPageSize() {
return pageSize <= 0 ? PAGE_SIZE : pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public