📄 getallzlservlet.java~9~
字号:
package com.j2ee.servlet.zlxz;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import com.j2ee.func.zlxz.*;
import java.sql.*;
public class GetAllZlServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=GBK";
//Initialize global variables
public void init() throws ServletException {
}
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
String sortid = request.getParameter("sortid");
String sorttype = request.getParameter("sorttype");
String pagenos = request.getParameter("pageno");
if(pagenos==null){pagenos="1";}
int pageno = Integer.parseInt(pagenos);
String type = request.getParameter("type");
if (type.equals("get")) {
Vector vct = new Vector();
int count = 0, pagesize = 0;
ZlxzFunc nf = new ZlxzFunc(4, pageno, sortid, sorttype);
try {
vct = nf.getAllXz();
} catch (SQLException ex) {
}
try {
count = nf.getAllXzcount();
} catch (SQLException ex1) {
}
try {
pagesize = nf.getPagesize();
} catch (SQLException ex2) {
}
ZlxzFunc nf1 = new ZlxzFunc();
nf1.searchkey = "";
nf1.typep = "";//置该类的静态变量的值为空
request.setAttribute("vct", vct);
request.setAttribute("sortid", sortid); //排列字段
request.setAttribute("sorttype", sorttype); //排列类型
request.setAttribute("count", Integer.toString(count));
request.setAttribute("pageno", Integer.toString(pageno));
request.setAttribute("pagesize", Integer.toString(pagesize));
request.getRequestDispatcher("zlxzallmana.jsp").forward(request,
response);
} else if (type.equals("delete")) {
ZlxzInfo nif = new ZlxzInfo();
String ids=request.getParameter("id");
int id=Integer.parseInt(ids);
ZlxzFunc nf=new ZlxzFunc(id);
if(nf.deleteZl()){
request.getRequestDispatcher("GetAllZlServlet?type=get&pageno="+pageno+"&sortid="+sortid+"&sortype="+sorttype).forward(request,response);
}
} else if (type.equals("edit")) {
String ids = request.getParameter("id");
int id = Integer.parseInt(ids);
ZlxzFunc nf = new ZlxzFunc(id);
Vector vct = new Vector();
try {
vct = nf.SelectdetailZlxzinfo();
} catch (SQLException ex3) {
}
request.setAttribute("vct", vct);
request.getRequestDispatcher("zlxzmodify.jsp").forward(request,
response);
} else if (type.equals("save")) {
ZlxzInfo nif = new ZlxzInfo();
String ids=request.getParameter("id");
int id=Integer.parseInt(ids);
nif.setLoadman(request.getParameter("Loadman"));
nif.setLarge(request.getParameter("Large"));
nif.setLink(request.getParameter("Link"));
nif.setShortbrief(request.getParameter("shortbrief"));
nif.setType(request.getParameter("typep"));
nif.setTitle(request.getParameter("title"));
nif.setId(id);
ZlxzFunc nf = new ZlxzFunc(nif);
if (nf.upDateZl()) {
request.getRequestDispatcher("dosuccess.jsp?mess=操作成功").forward(
request, response);
}
}else if(type.equals("search")){
String searchkey=request.getParameter("searchkey");
String typep=request.getParameter("typep");
ZlxzFunc nf=new ZlxzFunc();
nf.searchkey=searchkey;
nf.typep=typep;
request.getRequestDispatcher("GetAllZlServlet?type=get&sortid="+sortid+"&sorttype="+sorttype).forward(request,response);
}
else if(type.equals("search")){
String searchkey=request.getParameter("searchkey");
String typep=request.getParameter("typep");
ZlxzFunc nf=new ZlxzFunc();
nf.searchkey=searchkey;
nf.typep=typep;
request.getRequestDispatcher("GetAllZlServlet?type=get&sortid="+sortid+"&sorttype="+sorttype).forward(request,response);
}
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
doGet(request, response);
}
//Clean up resources
public void destroy() {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -