人力资源管理系统毕业论文设计范文(JSP)(9)
return dao;
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return null;
}
}
Pagination类:
public class public class Pagination {
private int rowCount;
private int rowOfPage=15;
private int curPage = 1;
private int pageCount;
[版权所有:http://DOC163.com]
public Pagination() {
}
public Pagination(int rowCount) {
setRowCount(rowCount);
}
public Pagination(int rowCount, int rowOfPage) {
setRowCount(rowCount);
setRowOfPage(rowOfPage);
}
public void setRowCount(int rowCount){
this.rowCount=rowCount;
init();
}
public int getRowCount() {
return rowCount;
}
public void setCurPage(int pageNum) {
this.curPage = pageNum;
}
public void setRowOfPage(int rowOfPage) {
this.rowOfPage = rowOfPage;
init();
}
private void init(){
pageCount=(int) java.lang.Math.ceil((double)rowCount / (double)rowOfPage);
}
public int getCurPage(){
return curPage;
}
public int getPageCount(){
return pageCount;
}
public int getFirst() {
return 1;
} [资料来源:http://Doc163.com]
public int getNext() {
if (pageCount> curPage) {
return curPage+1;
} else {
return pageCount;
}
} [资料来源:Doc163.com]
public int getPrevious() {
if (curPage > 1){
return curPage - 1;
}
return 1;
} [资料来源:http://www.doc163.com]
public int getLast() {
return pageCount;
}
[资料来源:http://www.doc163.com]
public int getStartRow() {
return (this.curPage - 1) * this.rowOfPage;
}
[资料来源:http://doc163.com]
public int getEndRow() {
return curPage * this.rowOfPage;
}
}
{
private int rowCount;
private int rowOfPage=15;
private int curPage = 1;
private int pageCount;
public Pagination() { [资料来源:http://Doc163.com]
}
public Pagination(int rowCount) {
setRowCount(rowCount);
}
public Pagination(int rowCount, int rowOfPage) {
setRowCount(rowCount);
setRowOfPage(rowOfPage);
}
public void setRowCount(int rowCount){
this.rowCount=rowCount;
init();
}
public int getRowCount() {
return rowCount;
}
public void setCurPage(int pageNum) {
this.curPage = pageNum;
}
public void setRowOfPage(int rowOfPage) {
this.rowOfPage = rowOfPage;
init();
}
private void init(){
pageCount=(int) java.lang.Math.ceil((double)rowCount / (double)rowOfPage);
}
public int getCurPage(){
return curPage;
}
public int getPageCount(){ [来源:http://www.doc163.com]
return pageCount;
}
public int getFirst() {
return 1;
} [来源:http://Doc163.com]
public int getNext() {
if (pageCount> curPage) {
return curPage+1;
} else {
return pageCount;
}
} [资料来源:http://www.doc163.com]
public int getPrevious() {
if (curPage > 1){
return curPage - 1;
}
return 1;
}
public int getLast() {
return pageCount;
} [资料来源:www.doc163.com]
public int getStartRow() {
return (this.curPage - 1) * this.rowOfPage;
}
public int getEndRow() {
return curPage * this.rowOfPage;
}
}
Controller层代码:
Action类:
public abstract class Action {
protected final String SUCCESS="success";
protected final String FAILURE="failure";
protected ActionMessage message=new ActionMessage();
protected Connection conn;
protected abstract String execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException ;
public String process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setAttribute("message", message);
return execute(request, response);
}
public void setConn(Connection conn){
this.conn=conn;
}
protected abstract DTO initDTO(HttpServletRequest request);
protected abstract boolean validate(DTO dto); [资料来源:http://doc163.com]
}
ActionConfig类:
public class ActionConfig {
private static ActionConfig actionConfig;
private Map<String,ActionInfo> actionInfos=new HashMap<String, ActionInfo>();
private ActionConfig(URL url) throws JDOMException, IOException{
SAXBuilder builder=new SAXBuilder();
Document doc = builder.build(url);
List<Element> list = XPath.selectNodes(doc,"//action-config/action");
Iterator<Element> iter=list.iterator();
while(iter.hasNext()){
Element actionElt=iter.next();
ActionInfo actionInfo=getActionInfo(actionElt);
actionInfos.put(actionInfo.getPath(), actionInfo);
}
}
private ActionInfo getActionInfo(Element actionElt) {
ActionInfo action=new ActionInfo();
action.setPath(actionElt.getAttributeValue("path"));
action.setActionClass(actionElt.getAttributeValue("actionClass"));
List<Element> list = actionElt.getChildren();
Iterator<Element> iter=list.iterator();
[资料来源:www.doc163.com]
while(iter.hasNext()){
Element forwardElt=iter.next();
ActionForward forward=getForward(forwardElt);
action.addActionForward(forward);
}
return action;
}
private ActionForward getForward(Element forwardElt) {
ActionForward actionForward=new ActionForward();
actionForward.setName(forwardElt.getAttributeValue("name"));
actionForward.setPath(forwardElt.getAttributeValue("path"));
actionForward.setRedirect(Boolean.parseBoolean(forwardElt.getAttributeValue("redirect")));
return actionForward;
}
public static void init(URL url) throws JDOMException, IOException{
if(actionConfig==null){
actionConfig=new ActionConfig(url);
}
}
public static ActionInfo getActionInfo(String path){ [来源:http://www.doc163.com]
if(actionConfig==null){
System.out.println("没有初始化");