2013-03-11 222 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

相關問題