获取FormPanel的字段值

时间:2013-05-01 15:13:12

标签: gwt servlets field return-value

我在获取来自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();
        }

我见过this post,但它并没有真正解释该怎么做

1 个答案:

答案 0 :(得分:0)

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

TextBox lastName = new TextBox();
lastName.setName("LastName");