首页 > 分享 > 解决当FORM的ENCTYPE='multipart/form

解决当FORM的ENCTYPE='multipart/form

最新推荐文章于 2021-03-11 16:52:02 发布

happy4nothing 于 2006-06-28 16:55:00 发布

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-data

Solutions:

Solution A:

1. download http://www.servlets.com/cos/index.html
2. invoke getParameters() on com.oreilly.servlet.MultipartRequest

Solution B:

1. download http://jakarta.apache.org/commons/sandbox/fileupload/
2. invoke readHeaders() in
org.apache.commons.fileupload.MultipartStream

Solution C:

1. download http://users.boone.net/wbrameld/multipartformdata/
2. invoke getParameter on
com.bigfoot.bugar.servlet.http.MultipartFormData

Solution D:

Use Struts. Struts 1.1 handles this automatically.

> 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.

相关知识

文件上传模块formidable如何使用
Content type 'multipart/form
The standardized description of Flower Form
js上传文件带参数,并且,返回给前台文件路径,解析上传的xml文件,存储到数据库中
前端——table标签和form标签和控件:table,input的type类型,select和option,label,textarea
基于YOLO的植物病害识别系统:从训练到部署全攻略
教你搭建一个花卉识别系统(超级简单)
基于VGG16网络的花卉识别
第八章木本花卉课稿.ppt
墨脱毛兰,一个可能的“异常整齐花”型,兼论兰科中“异常整齐花”现象

网址: 解决当FORM的ENCTYPE='multipart/form https://m.huajiangbk.com/newsview810913.html

所属分类:花卉
上一篇: 白芸豆种植方法详解(时机不可错过
下一篇: 莲子种植(莲子的种植方法及产量(