public ActionForward add(ActionMapping mapping
HttpServletRequest request
TruckBaseForm tbf = (TruckBaseForm)form;
FormFile filename = tbf
String tempname =
if ( filename
// 取得上傳時間
Date dt = new Date() ;
long updatetime=dt
try{
//開始上傳文件
String filePath = this
InputStream stream = filename
// ByteArrayOutputStream baos = new ByteArrayOutputStream() ;
int position = filename
String type = filename
tempname =updatetime+type ;
OutputStream bos = new FileOutputStream(filePath +
//request
int bytesRead =
byte[] buffer = new byte[
while( (bytesRead = stream
bos
}
bos
stream
//上傳文件完成
}
catch(Exception e){
e
}
}
TruckBase tb = this
//tbSEV
int truckid = Integer
//保存後返回的int是主鍵的ID
int result = this
List list = new ArrayList();
//保存後再撈一遍數據
list = tbSEV
request
list = (ArrayList)dataSEV
request
TruckCard td = new TruckCard();
td = this
request
return mapping
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26855.html