0

我在获取来自 FormPanel 的字段值时遇到问题。我得到的唯一东西是此处表单中包含的图像是 servlet 代码,我使用的是 Apache Commons:

    // Create a new file upload handler
        ServletFileUpload upload1 = new ServletFileUpload();

        // Parse the request
        FileItemIterator iter;
        try {
            iter = upload1.getItemIterator(req);
            while (iter.hasNext()) {
                FileItemStream item = iter.next();
                String name = item.getFieldName();
                InputStream stream = item.openStream();
                if (item.isFormField()) {
                    System.out.println("Form field " + name + " with value "
                        + Streams.asString(stream) + " detected.");
                } else {
                    System.out.println("File field " + name + " with file name "
                        + item.getName() + " detected.");
                    // Process the input stream

                }
            }
        } catch (FileUploadException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

我看过这篇文章,但它并没有真正解释该怎么做

4

1 回答 1

0

就像@Colin Alworth 所说,必须为每个字段设置名称属性!

TextBox lastName = new TextBox();
lastName.setName("LastName");
于 2013-05-01T19:46:22.447 回答