




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、實(shí)驗(yàn)全過程記錄實(shí) 驗(yàn)名 稱上傳和下載時間地點(diǎn)姓 名 學(xué)號1、 實(shí)驗(yàn)?zāi)康模篐tml表單提交以及文件上傳下載熟練運(yùn)用Html表單提交以及文件上傳下載二、實(shí)驗(yàn)內(nèi)容:1、編寫如下html表單,并編寫servlet處理表單提交的請求,表單信息插入數(shù)據(jù)庫2、如下表單,輸入學(xué)號,點(diǎn)擊“下載簡歷”按鈕,實(shí)現(xiàn)下載該學(xué)生簡歷3、如下表單,輸入最小最大值,點(diǎn)擊提交按鈕,導(dǎo)出符合條件的學(xué)生信息到文本文件(csv文件)中,或者導(dǎo)出到excel文件(使用POI框架)三、實(shí)驗(yàn)用設(shè)備儀器及材料:軟件需求:Eclipse硬件需求:微型計(jì)算機(jī)四、實(shí)驗(yàn)方法及步驟:1. 編寫HTML頁面(1) 學(xué)號姓名密碼性別input type=
2、radio name=sex id=inlineRadio1 value=男 checked=checked / 男input type=radio name=sex id=inlineRadio2 value=女 checked=checked / 女年齡身高學(xué)院option value=A selectde軟件學(xué)院option value=B selectde計(jì)院option value=C selectde經(jīng)濟(jì)學(xué)院option value=D selectde馬克思主義學(xué)院option value=E selectde電氣學(xué)院照片簡歷提交(2) 簡歷下載 學(xué)號 下載 (3) 數(shù)據(jù)導(dǎo)出 年
3、齡-導(dǎo)出2. 編寫相應(yīng)的servlet(1)Part partPhoto = request.getPart(photo); Part resumePart = request.getPart(resume); UploadService upload = new UploadService(); StudentMessage message = new StudentMessage(); String photoName = upload.getFileName(partPhoto); String resumeName = upload.getFileName(resumePart); S
4、tring contextPath = (String) request.getAttribute(contextPath); upload.writeTo(resumeName, resumePart, contextPath); upload.writeTo(photoName, partPhoto,contextPath); String Id = request.getParameter(Id)+; String stuId = request.getParameter(stuId); String name = request.getParameter(name); String a
5、ge = request.getParameter(age); String sex = request.getParameter(sex); String password = request.getParameter(password); String height = request.getParameter(height); String collage = request.getParameter(collage); message.setAge(age!=)?Integer.parseInt(age):0); message.setCollage(collage); message
6、.setHeight(height); message.setName(name); message.setPassword(password); message.setSex(sex); message.setStuId(stuId); message.setPhoto(photoName); message.setResume(resumeName); InsertInto insert = new InsertInto(); UpdataService upDao = new UpdataService(); if(Id.equals()|Id=null) Id = System.cur
7、rentTimeMillis()+stuId; System.out.println(Id); message.setId(Id); if(insert.insertData(message) System.out.println(插入成功); request.getRequestDispatcher(/login.jsp).forward(request, response); else message.setId(Id); upDao.updata(message); request.getRequestDispatcher(/show.do).forward(request, respo
8、nse); (2)String stuId = request.getParameter(stuId); StudentMessage message = new StudentMessage(); message.setStuId(stuId); Connection conn = (Connection) request.getAttribute(dbconn); DownService down = new DownService(); String photoName = down.selectResume(message, conn); String photoPath = requ
9、est.getAttribute(contextPath) + File.separator+photoName;/ response.setContentType(getMimeType(photoName); /設(shè)置Content-Disposition response.setHeader(Content-Disposition, attachment;filename=+photoName); InputStream in = new FileInputStream(photoPath); ServletOutputStream out = response.getOutputStre
10、am(); byte buffer = new byte1024; int len = 0; while(len=in.read(buffer)0) out.write(buffer,0,len); in.close(); out.close();(3)int minAge = Integer.parseInt(request.getParameter(minAge); int maxAge = Integer.parseInt(request.getParameter(maxAge); Connection conn = (Connection) request.getAttribute(d
11、bconn); ExportExcelService export = new ExportExcelService(); List list = export.selectByAge(minAge, maxAge, conn); HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(學(xué)生表); sheet.setDefaultColumnWidth(15); HSSFCellStyle style = wb.createCellStyle(); HSSFRow row = sheet.createRow(
12、0); /style.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFCell cell = row.createCell(0); cell.setCellValue(學(xué)號); cell.setCellStyle(style); cell = row.createCell(1); cell.setCellValue(姓名); cell.setCellStyle(style); cell = row.createCell(2); cell.setCellValue(年齡); cell.setCellStyle(style); cell = row.cr
13、eateCell(3); cell.setCellValue(性別); cell.setCellStyle(style); cell = row.createCell(4); cell.setCellValue(身高); cell.setCellStyle(style); cell = row.createCell(5); cell.setCellValue(學(xué)院); cell.setCellStyle(style); cell = row.createCell(6); cell.setCellValue(密碼); cell.setCellStyle(style); cell = row.cr
14、eateCell(7); cell.setCellValue(照片); cell.setCellStyle(style); for (int i = 0; i list.size(); i+) row = sheet.createRow(i + 1); row.createCell(0).setCellValue(list.get(i).getStuId(); row.createCell(1).setCellValue(list.get(i).getName(); row.createCell(2).setCellValue(list.get(i).getAge(); row.createC
15、ell(3).setCellValue(list.get(i).getSex(); row.createCell(4).setCellValue(list.get(i).getHeight(); row.createCell(5).setCellValue(list.get(i).getCollage(); row.createCell(7).setCellValue(list.get(i).getPhoto(); row.createCell(6).setCellValue(list.get(i).getPassword(); try OutputStream out = response.getOutputStream(); response.reset(); response.setHeader(Content-disposition, attachment; filename=學(xué)生信息表.xls); response.setContentT
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- DB3713-T 251-2022 沂蒙綠茶質(zhì)量分級與質(zhì)量安全控制技術(shù)規(guī)程
- 2024秋七年級數(shù)學(xué)上冊 第6章 平面圖形的認(rèn)識(一)6.1 線段 射線 直線 1直線、射線、線段教學(xué)實(shí)錄(新版)蘇科版
- 10 父母多愛我(教學(xué)設(shè)計(jì))-2023-2024學(xué)年道德與法治三年級上冊統(tǒng)編版
- 某住宅小區(qū)市政配套工程施工組織設(shè)計(jì)
- 2024年春七年級歷史下冊 第二單元 遼宋夏金元時期 民族關(guān)系發(fā)展和社會變化 第13課 宋元時期的科技與中外交通教學(xué)實(shí)錄 新人教版
- 2024-2025學(xué)年新教材高中語文 第三單元 9.1 說“木葉”教學(xué)實(shí)錄 部編版必修下冊
- 2024年八年級生物上冊 4.1.5《根的結(jié)構(gòu)與功能》教學(xué)實(shí)錄1 (新版)濟(jì)南版
- 6 飛向藍(lán)天的恐龍教學(xué)設(shè)計(jì)-2023-2024學(xué)年四年級下冊語文統(tǒng)編版
- 7 大自然中的發(fā)現(xiàn) 第2課時 教學(xué)設(shè)計(jì)-2024-2025學(xué)年科學(xué)一年級上冊湘科版
- 8 裝扮我們的教室 教學(xué)設(shè)計(jì)-2023-2024學(xué)年道德與法治二年級上冊 統(tǒng)編版
- GB/T 7024-2008電梯、自動扶梯、自動人行道術(shù)語
- GB/T 35714-2017船舶推進(jìn)電動機(jī)
- GB/T 3077-2015合金結(jié)構(gòu)鋼
- GB/T 18179-2000金屬覆蓋層孔隙率試驗(yàn)潮濕硫(硫華)試驗(yàn)
- 導(dǎo)尿管的護(hù)理
- 婦科外陰鱗狀上皮內(nèi)瘤樣病變診療常規(guī)
- 眼科基礎(chǔ)知識完整版本課件
- 中醫(yī)養(yǎng)生學(xué)-課件
- 邊坡支護(hù)方案-土釘墻
- 合同的訂立課件
- 《老年服務(wù)禮儀與溝通技巧》說課課件
評論
0/150
提交評論