📄 baseinfoservlet.java
字号:
package org.qiming.tianke.servlet;
import java.io.IOException;
import java.io.PrintWriter;
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 org.qiming.tianke.bean.Causeinfo;
import org.qiming.tianke.common.DataBaseConnection;
import org.qiming.tianke.operate.BaseinfoOperate;
public class BaseinfoServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public BaseinfoServlet() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* 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 {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
this.doPost(request, response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @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 doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
HttpSession session=request.getSession(true);
String flag=request.getParameter("flag");
String operate=request.getParameter("operate");
if("select".equals(operate)){
if("cause".equals(flag)){
String cond="1=1";
List rsList=BaseinfoOperate.causeinfoQuery(cond);
session.setAttribute("rsList", rsList);
response.sendRedirect("archive/baseinfomanager/cause_list.jsp");
}
if("quanzong".equals(flag)){
String cond="1=1";
List qzList=BaseinfoOperate.quanzonginfoQuery(cond);
session.setAttribute("qzList", qzList);
response.sendRedirect("archive/baseinfomanager/quanzong_list.jsp");
}
if("comefile".equals(flag)){
String cond="1=1";
List fileList=BaseinfoOperate.comefileMethodQuery(cond);
session.setAttribute("fileList", fileList);
response.sendRedirect("archive/baseinfomanager/comefilemethod_list.jsp");
}
if("save".equals(flag)){
String cond="1=1";
List saveList=BaseinfoOperate.saveQuery(cond);
session.setAttribute("saveList", saveList);
response.sendRedirect("archive/baseinfomanager/saveperiod_list.jsp");
}
if("leader".equals(flag)){
String cond="1=1";
List leaderList=BaseinfoOperate.leaderQuery(cond);
session.setAttribute("leaderList", leaderList);
response.sendRedirect("archive/baseinfomanager/leader_list.jsp");
}
if("class".equals(flag)){
String cond="";
String target=request.getParameter("target");
List list=BaseinfoOperate.getOneClassinfoPage(target,cond);
List classlist=(List)list.get(4);
session.setAttribute("list", list);
session.setAttribute("classlist", classlist);
response.sendRedirect("archive/baseinfomanager/sort_list.jsp");
}
}
if("insert".equals(operate)){
//展现事由新增
if("cause".equals(flag)){
response.sendRedirect("archive/baseinfomanager/cause_add.jsp");
}
if("add".equals(flag)){
// DataBaseConnection conn=new DataBaseConnection();
// String sql="select max(causeid) from cause";
// int causeid=Integer.parseInt(conn.getKey(sql));
String causename=request.getParameter("causename");
String causedesc=request.getParameter("causedesc");
Causeinfo causeinfo=new Causeinfo(causename,causedesc);
boolean is=BaseinfoOperate.insertCause(causeinfo);
if(is){
response.sendRedirect("./BaseinfoServlet?operate=select&flag=cause");
}else{
response.sendRedirect("common/tree/error.jsp");
}
}
}
if("delete".equals(operate)){
if("cause".equals(flag)){
int causeid=Integer.parseInt(request.getParameter("causeid"));
boolean is=BaseinfoOperate.deleteCause(causeid);
if(is){
response.sendRedirect("./BaseinfoServlet?operate=select&flag=cause");
}else{
response.sendRedirect("common/tree/error.jsp");
}
}
}
if("modify".equals(operate)){
//准备数据
if("cause".equals(flag)){
int causeid=Integer.parseInt(request.getParameter("causeid"));
Causeinfo cause=BaseinfoOperate.getOneCause(causeid);
session.setAttribute("cause", cause);
response.sendRedirect("archive/baseinfomanager/cause_modify.jsp");
}
}
if("update".equals(operate)){
if("cause".equals(flag)){
int causeid=Integer.parseInt(request.getParameter("causeid"));
String causename=request.getParameter("causename");
String causedesc=request.getParameter("causedesc");
Causeinfo cause=new Causeinfo(causeid,causename,causedesc);
boolean is=BaseinfoOperate.updateCause(cause);
if(is){
response.sendRedirect("./BaseinfoServlet?operate=select&flag=cause");
}else{
response.sendRedirect("common/error.jsp");
}
}
}
out.flush();
out.close();
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -