版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、實(shí)驗(yàn)全過程記錄實(shí) 驗(yàn)名 稱上傳和下載時(shí)間地點(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)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2026年建筑智能化對房地產(chǎn)價(jià)值的促進(jìn)
- 企業(yè)員工心理健康培訓(xùn)材料
- 房地產(chǎn)企業(yè)質(zhì)量管理與安全規(guī)范
- 初中語文教學(xué)設(shè)計(jì)全冊解析
- 企業(yè)材料采購流程與標(biāo)準(zhǔn)說明
- 2026年大型公共建筑的電氣消防設(shè)計(jì)
- 傳染病管理報(bào)告規(guī)范制度
- 2026年房地產(chǎn)企業(yè)的稅務(wù)合規(guī)管理流程
- 2026年施工質(zhì)量對結(jié)構(gòu)安全的影響
- 新能源車售后服務(wù)工作流程
- 2026北京大學(xué)餐飲中心招聘勞動(dòng)合同制人員1人筆試參考題庫及答案解析
- 2025年安吉縣輔警招聘考試真題匯編附答案
- 貨運(yùn)代理公司操作總監(jiān)年度工作匯報(bào)
- 物業(yè)管理?xiàng)l例實(shí)施細(xì)則全文
- 電化學(xué)儲能技術(shù)發(fā)展與多元應(yīng)用
- 2026年安全員之C證(專職安全員)考試題庫500道及完整答案【奪冠系列】
- 掩體構(gòu)筑與偽裝課件
- 2026年包頭鐵道職業(yè)技術(shù)學(xué)院單招職業(yè)技能考試題庫帶答案詳解
- 2025年福建省高二學(xué)業(yè)水平考試信息技術(shù)試題(含答案詳解)
- 林業(yè)地類代碼表
- 輔導(dǎo)員工作談心談話分析-輔導(dǎo)員談心談話案例
評論
0/150
提交評論