?? queryblockpublishdo.java
字號:
package com.lovo.servlet;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.lovo.factory.BOFactory;
import com.lovo.po.BlockPO;
import com.lovo.po.PublishPO;
import com.lovo.po.UserPO;
import com.lovo.util.Page;
public class QueryBlockPublishDO extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
response.setCharacterEncoding("utf-8");
HttpSession session = request.getSession(true);
String areaIdStr = request.getParameter("areaId");
String blockIdStr = request.getParameter("blockId");
String currPageStr = request.getParameter("page");
// int areaId = Integer.parseInt(areaIdStr);
int blockId = 0;
try {
blockId = Integer.parseInt(blockIdStr);
} catch (NumberFormatException e) {
blockId = ((BlockPO)session.getAttribute("block")).getId();
}
int currPage = 1;
try {
currPage = Integer.parseInt(currPageStr);
} catch (NumberFormatException e) {
currPage = 1;
}
if(currPage <= 0) {
currPage = 1;
}
int maxRows = BOFactory.getPublishBOInstance().queryPublishMaxRowsInBlock(blockId);
List<UserPO> blockAdminList = BOFactory.getUserBOInstance().queryBlockAdmin(blockId);
Page pubPage = new Page();
pubPage.setCurrPage(currPage);
pubPage.setMaxRows(maxRows);
int maxPages = maxRows % pubPage.getPageRows() == 0 ? maxRows / pubPage.getPageRows() : maxRows / pubPage.getPageRows() + 1;
if(currPage >= maxPages) {
currPage = maxPages;
pubPage.setCurrPage(currPage);
}
List<PublishPO> publishList = BOFactory.getPublishBOInstance().queryPubByBlockid(blockId, pubPage);
BlockPO block = BOFactory.getBlockBOInstance().queryBlockById(blockId);
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String nowTime = sdf.format(now);
session.setAttribute("publishList", publishList);
session.setAttribute("blockAdminList", blockAdminList);
session.setAttribute("nowTime", nowTime);
session.setAttribute("block", block);
session.setAttribute("pubPage", pubPage);
//System.out.println("blockID="+block.getId());
response.sendRedirect("../web/jsp/block.jsp?maxPages="+maxPages);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -