📄 pageraction.java
字号:
package com.pegasus.framework.component.taglib.test;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
public class PagerAction extends Action {
/**
* Method execute
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
//System.out.println("PagerAction doExecute" + mapping.getInput());
List objList = new ArrayList();
PagerForm actionForm = (PagerForm)form;
int fetchSize = 0;
int pageNo = 0;
if(actionForm.getPageNo() == null || actionForm.getPageNo().equals("")) {
pageNo = 1;
} else {
pageNo = new Integer(actionForm.getPageNo()).intValue();
}
if(actionForm.getFectchSize() == null|| actionForm.getPageNo().equals("")) {
fetchSize = 10;
} else {
fetchSize = new Integer(actionForm.getFectchSize()).intValue();
}
int max = 300;
if((pageNo-1) * fetchSize + fetchSize <= 300) {
max = (pageNo-1) * fetchSize + fetchSize;
}
for(int i = (pageNo - 1)* fetchSize;i <= max;i++) {
String[] objs = new String[3];
objs[0] = "a" + i;
objs[1] = "b" + i;
objs[2] = "c" + i;
objList.add(objs);
}
actionForm.setTotalObjectCount("300");
request.setAttribute("objList",objList);
//System.out.println("mapping.getInput(): " + mapping.getInput());
return new ActionForward(mapping.getInput());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -