On The Way

          解決當FORM的ENCTYPE="multipart/form-data" 時request.getParameter()獲取不到值的方法

          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/fileupload/ 
              2. invoke readHeaders() in org.apache.commons.fileupload.MultipartStream
              Or
              1. Invoke parseRequest(request) on org.apache.commons.fileupload.FileUploadBase which returns list of org.apache.commons.fileupload.FileItem objects.
             2. Invoke isFormField() on each of the FileItem objects. This determines whether the file item is a form paramater or stream of uploaded file.
             3. 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.

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

          posted on 2008-03-26 10:38 梁健 閱讀(2731) 評論(2)  編輯  收藏 所屬分類: jsp/servlet

          Feedback

          # re: 解決當FORM的ENCTYPE="multipart/form-data" 時request.getParameter()獲取不到值的方法 2009-03-03 10:52 fd

          沒人看的懂你說的。。。要么就別寫  回復  更多評論   

          # re: 解決當FORM的ENCTYPE="multipart/form-data" 時request.getParameter()獲取不到值的方法 2012-05-18 17:30 路人甲

          smartupload.getRequest().getParameter("cwname")這樣就可以了  回復  更多評論   


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 苍南县| 合水县| 连城县| 玉环县| 余姚市| 宣城市| 晋州市| 眉山市| 日土县| 南开区| 格尔木市| 仪征市| 商城县| 松潘县| 图们市| 新宁县| 汝州市| 洛南县| 介休市| 博湖县| 保山市| 蓝山县| 镇江市| 本溪| 施秉县| 安阳县| 鄂托克前旗| 深州市| 白沙| 蒙山县| 进贤县| 富蕴县| 岳西县| 金塔县| 宝兴县| 东乡族自治县| 进贤县| 吴川市| 旺苍县| 玛纳斯县| 盘山县|