?? mcinfoservlet.java
字號:
package com.lmh.servlet.admin;
import java.io.IOException;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.lmh.dao.impl.OracleMcDAO;
import com.lmh.dao.impl.OracleMcTypeDAO;
import com.lmh.dao.vo.McBean;
public class McInfoServlet extends HttpServlet {
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request
* the request send by the client to the server
* @param response
* the response send by the server to the client
* @throws ServletException
* if an error occurred
* @throws IOException
* if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
int maxid = -1;
int minid = -1;
String sname = null;
int pastart = -1;
int paend = -1;
int countAll = 0;
int curPage = 1;
int totalPage = 0;
int pagesize = 0;
double ptrstart = -1;
double ptrend = -1;
int nid = -1;
String smctag = "";
OracleMcDAO mcDao = new OracleMcDAO();
OracleMcTypeDAO mcTypeDao = new OracleMcTypeDAO();
String action = request.getParameter("action");
try {
smctag = request.getParameter("smctag");
} catch (Exception en) {
}
try {
nid = Integer.parseInt(request.getParameter("mcID"));
} catch (Exception en) {
}
try {
ptrstart = Integer.parseInt(request.getParameter("ptrstart"));
} catch (Exception en) {
}
try {
ptrend = Integer.parseInt(request.getParameter("ptrend"));
} catch (Exception en) {
}
try {
maxid = Integer.parseInt(request.getParameter("maxid"));
} catch (Exception en) {
}
try {
minid = Integer.parseInt(request.getParameter("minid"));
} catch (Exception en) {
}
try {
sname = request.getParameter("sname");
} catch (Exception en) {
}
try {
curPage = Integer.parseInt(request.getParameter("curPage"));
} catch (Exception en) {
}
try {
pagesize = Integer.parseInt(this.getServletConfig()
.getInitParameter("pagesize"));
} catch (Exception en) {
}
pastart = (curPage - 1) * pagesize + 1;
paend = curPage * pagesize;
/**
* 符合條件的總記錄數
*/
countAll = mcDao.getCount(sname, ptrstart, ptrend, maxid, minid);
totalPage = (countAll - 1) / pagesize + 1;
request.setAttribute("countAll", countAll);
request.setAttribute("curPage", curPage);
request.setAttribute("totalPage", totalPage);
List mcTypeList = mcTypeDao.searchMcType(-1, null);
request.setAttribute("mcTypeList", mcTypeList);
if (action != null && action.equals("delete")) {
mcDao.deleteMc(nid);
} else if (action != null && action.equals("update")) {
if (nid != -1) {
McBean mcBean = new McBean();
mcBean.setNid(nid);
if (smctag.equals("是")) {
mcBean.setSmctag("1");
} else if(smctag.equals("否")){
mcBean.setSmctag("0");
}
mcDao.updateMc(mcBean);
countAll = mcDao.getCount();
}
}
List mcList = mcDao.selectMc(-1, sname, ptrstart, ptrend, maxid, minid,
pastart, paend);
request.setAttribute("mcList", mcList);
RequestDispatcher rd = null;
rd = request.getRequestDispatcher("/admin/mcManager/mcInfo.jsp");
rd.forward(request, response);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -