Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/381.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 筛选器中的parseRequest()将ActionForm返回为空_Java_Filter_Struts 1_Apache Commons Fileupload - Fatal编程技术网

Java 筛选器中的parseRequest()将ActionForm返回为空

Java 筛选器中的parseRequest()将ActionForm返回为空,java,filter,struts-1,apache-commons-fileupload,Java,Filter,Struts 1,Apache Commons Fileupload,我在Struts 1.2应用程序中添加了一个过滤器,该过滤器在将请求提交到ActionForm之前触发。我的jsp中有一个多部分/表单数据,因此我使用apache.commons.FileUpload解析请求,并通过使用ServletFileUpload类的parseRequest(HttpServletRequest)-方法获取我的特定请求参数 处理完成并将请求传递到actionForm后,我的表单中没有数据。我知道一个请求只能被解析一次,因为我已经在我的过滤器中解析了它,所以我不能以我的形式

我在Struts 1.2应用程序中添加了一个过滤器,该过滤器在将请求提交到ActionForm之前触发。我的jsp中有一个多部分/表单数据,因此我使用apache.commons.FileUpload解析请求,并通过使用ServletFileUpload类的parseRequest(HttpServletRequest)-方法获取我的特定请求参数

处理完成并将请求传递到actionForm后,我的表单中没有数据。我知道一个请求只能被解析一次,因为我已经在我的过滤器中解析了它,所以我不能以我的形式获取数据

即使在筛选器中解析请求之后,表单中的数据是否还有其他可用方式

这是我在过滤器中使用的代码

List<FileItem> multiparts = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(servletRequest);
            for (FileItem item : multiparts) {

                if (item.isFormField()) {
                    String name = item.getFieldName();
                    stripXSS(item.getString());  
                }
            }
但这也带来了同样的问题

ServletFileUpload upload = new ServletFileUpload();
            FileItemIterator iterator = upload.getItemIterator(servletRequest);
            while(iterator.hasNext()){


                FileItemStream item = iterator.next();
                InputStream stream = item.openStream();
                if(item.isFormField()){
                    String name = item.getFieldName();
                    String value = Streams.asString(stream);             
                    stripXSS(item.getString());
                }
            }