




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、實驗全過程記錄實 驗名 稱上傳和下載時間地點姓 名 學號1、 實驗目的:Html表單提交以及文件上傳下載熟練運用Html表單提交以及文件上傳下載二、實驗內(nèi)容:1、編寫如下html表單,并編寫servlet處理表單提交的請求,表單信息插入數(shù)據(jù)庫2、如下表單,輸入學號,點擊“下載簡歷”按鈕,實現(xiàn)下載該學生簡歷3、如下表單,輸入最小最大值,點擊提交按鈕,導出符合條件的學生信息到文本文件(csv文件)中,或者導出到excel文件(使用POI框架)三、實驗用設(shè)備儀器及材料:軟件需求:Eclipse硬件需求:微型計算機四、實驗方法及步驟:1. 編寫HTML頁面(1) 學號姓名密碼性別input type=
2、radio name=sex id=inlineRadio1 value=男 checked=checked / 男input type=radio name=sex id=inlineRadio2 value=女 checked=checked / 女年齡身高學院option value=A selectde軟件學院option value=B selectde計院option value=C selectde經(jīng)濟學院option value=D selectde馬克思主義學院option value=E selectde電氣學院照片簡歷提交(2) 簡歷下載 學號 下載 (3) 數(shù)據(jù)導出 年
3、齡-導出2. 編寫相應的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(學生表); 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(學號); 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(學院); 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=學生信息表.xls); response.setContentT
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 急診科醫(yī)院保安崗位職責
- 快餐行業(yè)食品供貨應急預案措施
- 農(nóng)林牧漁培訓效果評價范文
- 基層婦女干部培訓班學習心得體會
- 學校扶貧安全教育計劃
- 中醫(yī)藥健康管理科技應用工作計劃
- 文化傳媒公司客戶投訴流程
- 英語商務郵件范文財務結(jié)算
- 湖南文藝出版社六年級音樂上冊教學評價計劃
- 危險廢物處理重大危險源監(jiān)控措施
- 國家電網(wǎng)考試歷年真題(含解析)
- 工商局版法定代表人證明及授權(quán)委托書
- 省級糖尿病??谱o士選拔試題題庫及答案
- 2022年廣東高考成績一分一段表重磅出爐
- 部編版九年級語文上冊教案
- 2023-2024學年黑龍江省寧安市初中語文七年級下冊期末高分通關(guān)試卷
- 重癥監(jiān)護ICU護理實習生出科考試試題及答案
- GB/T 6075.3-2011機械振動在非旋轉(zhuǎn)部件上測量評價機器的振動第3部分:額定功率大于15 kW額定轉(zhuǎn)速在120 r/min至15 000 r/min之間的在現(xiàn)場測量的工業(yè)機器
- GB/T 15558.1-2015燃氣用埋地聚乙烯(PE)管道系統(tǒng)第1部分:管材
- GB/T 11060.8-2020天然氣含硫化合物的測定第8部分:用紫外熒光光度法測定總硫含量
- 國開??啤锻鈬膶W》十年期末考試題庫及答案
評論
0/150
提交評論