html 多部分表单中输入文本字段的值 [英] values of input text fields in a html multipart form

查看:23
本文介绍了html 多部分表单中输入文本字段的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个带有字段的 html 表单的 java 服务器端应用程序中使用 Apache Commons FileUpload:

I use Apache Commons FileUpload in a java server-side app that has a html form with fields :

  1. 确定的目的地将是填写的电子邮件地址目标邮箱

  1. a destination fied that will be filled with email address of the destination mailbox

带有发件人消息的消息文本

a message text with a message of the sender

推荐答案

我猜您正在使用 FileItemIterator 来迭代请求中的项目.迭代器 next() 方法返回一个 FileItemStream(不是 FileItem).打开该对象上的流并将其转换为这样的字符串:

I am guessing you are using a FileItemIterator to iterate the items in the request. The iterators next() method returns a FileItemStream (not a FileItem). Open the stream on that object and turn it into a string like this:

import org.apache.commons.fileupload.util.Streams;
...
FileItemStream item = iterator.next();
InputStream stream = item.openStream();
String name = item.getFieldName();
String value = Streams.asString(stream);

其他答案建议的getString方法是FileItem接口上的一个方法.

The getString method suggested by other answers is a method on the FileItem interface.

这篇关于html 多部分表单中输入文本字段的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆