日期:2014-05-18  浏览次数:20629 次

form中file类型的type如何取得值。
如题。

代码如下:
<form   action= "ProjectApplication.jsp "     method= "post "           name= "form1 "     >

  <input   name= "ProjectName "   type= "text "   >
  <input   name= "file "   type= "file "     >
    <input   type= "submit "   name= "Submit "   value= "提交 ">    

</form>

如何取得projectname中的字符串以及file中的字符串。

request.getParameter( "projectname ")
request.getParameter( "file ")
都取不到值,为null

谢谢

------解决方案--------------------
在ProjectApplication.jsp里面取这两个值吗?
------解决方案--------------------
在 <form enctype= "multipart/form-data " > 中加上一个属性 enctype= "multipart/form-data "
然后在formbean中建一个类型为 FormFile 的变量,在action中用formbean.get()方法得到
------解决方案--------------------
3楼说的对,顶
------解决方案--------------------
form中加上enctype= "multipart/form-data "是必须的