首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >获取FormPanel的字段值

获取FormPanel的字段值
EN

Stack Overflow用户
提问于 2013-05-01 23:13:12
回答 1查看 429关注 0票数 0

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

代码语言:javascript
复制
    // 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,但它并没有真正解释该怎么做

EN

回答 1

Stack Overflow用户

发布于 2013-05-02 03:46:22

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

代码语言:javascript
复制
TextBox lastName = new TextBox();
lastName.setName("LastName");
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16320850

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档