欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
解決當FORM的ENCTYPE="multipart/form-data" 時(shí)reques...

今天在原來(lái)上傳文件頁(yè)面的基礎上,想添加一段文件的簡(jiǎn)介

因為同時(shí)要上傳文件,所以ENCTYPE="multipart/form-data" 必須要加在form里面

可是這樣的話(huà),我再Servlet里面用request.getParameter()方法無(wú)論如何都只是獲得null值,

不是一般的郁悶,百度了一下,有人出現了同樣的問(wèn)題可是它用的是JSPsmartupload組件實(shí)現文件上傳的,

而我用的commons fileupload組件,仔細看了一下這個(gè)組件的api,可是英語(yǔ)太差了,沒(méi)有發(fā)現相關(guān)的信息

我又嘗試用session傳遞參數,可是發(fā)現有點(diǎn)麻煩,因為在表單提交之時(shí)你就得賦給session表單上它的數值,

這似乎要JavaScript,可是偶也不會(huì ),

后來(lái)只有g(shù)oogle了,搜索了一些中文網(wǎng)頁(yè),也沒(méi)有找到資料,試試不限制語(yǔ)言,呵呵呵,一大片,后來(lái)被俺發(fā)

現了這個(gè)

I cannot read the submitter using request.getParameter("submitter") (it returns null). ]

Situation:Javax.servlet.HttpServletRequest.getParameter(String) returns null when the ContentType is multipart/form-dataSolutions:Solution A:1. download http://www.servlets.com/cos/index.html2. invoke getParameters() on com.oreilly.servlet.MultipartRequestSolution B:1. download http://jakarta.apache.org/commons/sandbox/fileupload/2. invoke readHeaders() inorg.apache.commons.fileupload.MultipartStreamSolution C:1. download http://users.boone.net/wbrameld/multipartformdata/2. invoke getParameter oncom.bigfoot.bugar.servlet.http.MultipartFormDataSolution D:Use Struts. Struts 1.1 handles this automatically.
說(shuō)是不詳細,接著(zhù)往下看,另一種解決方法
> Solution B:
> 1. download
> http://jakarta.apache.org/commons/sandbox/fileupload/
> 2. invoke readHeaders() in
> org.apache.commons.fileupload.MultipartStream

The Solution B as given by my dear friend is a bit hectic and a bit complex :(
We can try the following solution which I found much simpler (at least in usage).

1. Download one of the versions of UploadFile from http://jakarta.apache.org/commons/fileupload/
2. Invoke parseRequest(request) on org.apache.commons.fileupload.FileUploadBase which returns list of org.apache.commons.fileupload.FileItem objects.
3. Invoke isFormField() on each of the FileItem objects. This determines whether the file item is a form paramater or stream of uploaded file.
4. Invoke getFieldName() to get parameter name and getString() to get parameter value on FileItem if it's a form parameter. Invoke write(java.io.File) on FileItem to save the uploaded file stream to a file if the FileItem is not a form parameter.

按照上面的步驟來(lái),果然一切都ok,GOOGLE真不錯,主要是getFieldName和getString,
雖然說(shuō)這種做法有一點(diǎn)麻煩,但稍微判斷加工一下,總比獲取不到強
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
基于表單的文件上傳
CMS項目總結:18、文件上傳commons
Apache commons FileUpload 組件
關(guān)于httpclient中MultipartPostMethod類(lèi)上傳文件的一點(diǎn)感受
Servlet 文件上傳 | 菜鳥(niǎo)教程
SpringMVC上傳文件的三種方式
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久