?? carmanageinfosave.java
字號(hào):
package com.logistic.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpSession;
import java.sql.ResultSet;
import java.sql.Statement;
import com.logistic.business.CarManager;
import com.logistic.data.DataConnect;
public class CarManageInfoSave extends HttpServlet {
private static final long serialVersionUID = -2305260907601477327L;
DataConnect dc=new DataConnect();
HttpSession session;
Statement stat=null;
ResultSet rs=null;
RequestDispatcher requestdispatcher;
int flag=0;
String cid=null;
String did=null;
String tid=null;
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("GB2312");
response.setContentType("text/html;charset=gb2312");
session=request.getSession();
/*-----------獲得頁(yè)面carmanagesave.jsp提交的數(shù)據(jù),進(jìn)行檢驗(yàn)合法后插入數(shù)據(jù)庫(kù)------------*/
cid=(String)request.getParameter("carnumber");//車(chē)輛號(hào)碼
did=(String)request.getParameter("driverid"); //駕駛員編號(hào)
tid=(String)request.getParameter("carteamid");//車(chē)隊(duì)編號(hào)
//如果車(chē)輛號(hào)碼,駕駛員編號(hào),車(chē)隊(duì)編號(hào)三項(xiàng)中有一個(gè)為null就跳轉(zhuǎn)到errorpage.jsp頁(yè)面
if(cid==null||did==null||tid==null){
session.setAttribute("errors","添加車(chē)輛管理失敗,*標(biāo)識(shí)項(xiàng)必須填寫(xiě)!");
requestdispatcher=request.getRequestDispatcher("/errors/errorpage.jsp");
requestdispatcher.forward(request, response);
}else{
try{
flag=-10;
CarManager cm=new CarManager();
flag=cm.AddCarManager(cid, did, tid);
if(flag>0){ //車(chē)輛管理數(shù)據(jù)添加成功跳轉(zhuǎn)到carmanagesave.jsp頁(yè)面
session.setAttribute("success", "車(chē)輛管理信息添加成功!");
requestdispatcher=request.getRequestDispatcher("/viewpage/datainput/carmanagesave.jsp");
requestdispatcher.forward(request,response);
}else{ //車(chē)輛管理數(shù)據(jù)添加失敗跳轉(zhuǎn)到errorpage.jsp頁(yè)面
session.setAttribute("errors", "車(chē)輛管理信息添加失敗!");
requestdispatcher=request.getRequestDispatcher("/errors/errorpage.jsp");
requestdispatcher.forward(request,response);
}
}catch(Exception ex){flag=-1;ex.printStackTrace();}finally{dc.close();}
}
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -