我的Servlet如何从multipart/form-data表单接收参数? [英] How can my Servlet receive parameters from a multipart/form-data form?
本文介绍了我的Servlet如何从multipart/form-data表单接收参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含这段代码的页面:
I have a page that has this piece of code:
<form action="Servlet" enctype="multipart/form-data">
<input type="file" name="file">
<input type="text" name="text1">
<input type="text" name="text2">
</form>
当我在Servlet中使用request.getParameter("text1");
时,它显示为null.如何使我的Servlet接收参数?
When I use request.getParameter("text1");
in my Servlet it shows null. How can I make my Servlet receive the parameters?
推荐答案
所有请求参数都嵌入到多部分数据中.您必须使用Commons File Upload这样的工具提取它们: http://commons.apache.org/fileupload/
All the request parameters are embedded into the multipart data. You'll have to extract them using something like Commons File Upload: http://commons.apache.org/fileupload/
这篇关于我的Servlet如何从multipart/form-data表单接收参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文