?? logtableaction.java
字號:
package com.action;
import org.apache.struts.action.*;
import java.io.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.sql.SQLException;
import com.bean.CompUser;
import com.dao.*;
import com.tool.pagetool.*;
import com.tool.QueryStrCreator;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class LogTableAction extends Action{
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
request.setCharacterEncoding("gb2312");
response.setContentType("text/html;charset=gb2312");
String currentPageStr = request.getParameter("currentPage");
int currentPage = 1; //當前頁碼
int size = 20; //每頁的記錄數
try { //防止從地址欄直接輸入非法頁碼
if (currentPageStr != null) currentPage = new Integer(
currentPageStr).intValue();
} catch (Exception e) {
e.printStackTrace();
}
//處理分頁
//會話中是否已有分頁生成工具
PageTool pageTool = null;
HttpSession session = request.getSession();
pageTool = (PageTool) session.getAttribute("LogTablePageTool"); //有,則直接拿來用
if (pageTool == null) { //沒有,則新建,并放進會話中,以備下次用
pageTool = PageToolBuilder.builder(new LogTableDAO());
session.setAttribute("LogTablePageTool", pageTool);
}
//由分頁工具生成分頁
Page page = null;
try {
page = pageTool.createPage(currentPage, size);
} catch (SQLException ex) {
ex.printStackTrace();
}
//將分頁放進請求中,分發到下一個頁面顯示
request.setAttribute("allLogerPage", page);
return mapping.findForward("readLoger");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -