2013-03-11 154 views
2

我在我的index.jsp使用此:JSP的request.getParameter(串)返回null

<FORM enctype="multipart/form-data" action="saveFile.jsp" method="POST"> 
Choose the file To Upload:<br> 
<INPUT name="Filename" placeholder="Name to give your file"/> 
<INPUT name="File" type="file" accept ="image/jpeg"/> 
<INPUT TYPE="submit" VALUE="Send File" />  
</FORM> 

在saveFile.jsp字符串名称应使用的request.getParameter获得从输入字段中的值(“文件名”),但它返回的值为空;

String name = request.getParameter("Filename"); 

我知道请求被发送,因为该文件传递给我,但我无法弄清楚为什么我的代码部分失败。

+3

请看看该职位:http://stackoverflow.com/questions/1545717/issue -with-多形式的数据 – 2013-03-11 13:55:44

+0

谢谢它给了我一直在寻找的答案,请把它作为一个答案,所以我可以接受它 – 2013-03-12 14:42:51

+0

THX非常多。完成... – 2013-03-12 14:59:46

回答

0

你没有任何值设置为文本字段

<INPUT name="Filename" placeholder="Name to give your file" value="this should come"/> 

现在使用

String name = request.getParameter("Filename"); 
+0

也许在网页上输入了一个值? – 2013-03-11 13:55:46

+0

在网页上输入了值,甚至将您的复制到我的

中,并将您的request.getParameter粘贴到我的saveFile.jsp中,结果为空 – 2013-03-11 13:59:31

相关问题