最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

上傳文件時(shí)后臺的request對象時(shí)空的,tempFile里面什么都沒有

上傳文件時(shí)后臺的request對象時(shí)空的,tempFile里面什么都沒有

Eyre悱 2017-08-28 18:11:21
public void doPost(HttpServletRequest req, HttpServletResponse resp) ? ? ?throws ServletException, IOException { ? System.out.println("已接收到請求"); ? //獲取前臺傳過來的流信息 ? InputStream fileSource = req.getInputStream(); ? //臨時(shí)文件存儲位置 ? String tempFileName = "D:/temp/tempFile"; ? //創(chuàng)建臨時(shí)文件 ? File tempFile = new File(tempFileName); ? //輸出流指向臨時(shí)文件 ? FileOutputStream outputStream = new FileOutputStream(tempFile); ? byte b[] = new byte[1024]; ? int n; ? //從輸入流讀取內(nèi)容寫入到輸出流 ? while(( n = fileSource.read(b)) != -1){ ? ? ?outputStream.write(b, 0, n); ? } ? //關(guān)閉輸入、輸出流 ? outputStream.close(); ? fileSource.close();}
查看完整描述

2 回答

已采納
?
勝利女神在微笑

TA貢獻(xiàn)67條經(jīng)驗(yàn) 獲得超59個(gè)贊

????????????????DiskFileItemFactory?factory?=?new?DiskFileItemFactory();
		factory.setSizeThreshold(4096);?//?設(shè)置緩沖區(qū)大小,這里是4kb
		factory.setRepository(new?File(this.getServletContext().getRealPath("WEB-INF")));//?設(shè)置緩沖區(qū)目錄
		ServletFileUpload?upload?=?new?ServletFileUpload(factory);
		List<FileItem>?items?=?upload.parseRequest(request);//?得到所有的文件
		Iterator<FileItem>?i?=?items.iterator();
		if?(!i.hasNext())?{
			logger.warn("receiveFile?,file?not?exists!");
			return;
		}
		FileItem?fi?=?(FileItem)?i.next();
		fi.getInputStream()


查看完整回答
1 反對 回復(fù) 2017-08-29
?
勝利女神在微笑

TA貢獻(xiàn)67條經(jīng)驗(yàn) 獲得超59個(gè)贊

別忘了采納

查看完整回答
反對 回復(fù) 2017-08-29
  • 2 回答
  • 0 關(guān)注
  • 1540 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號