values of input text fields in a html multipart form

前端 未结 4 2281
走了就别回头了
走了就别回头了 2020-12-17 23:47

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

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

4条回答
  •  轮回少年
    2020-12-18 00:14

    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);
    

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

提交回复
热议问题