2
文件後我有一個HTML頁面是這樣的:閱讀HttpServletRequest的
<FORM METHOD="POST" ACTION="http://localhost:8080/Appli/page/public/envoiPjExterne.seam" enctype="multipart/form-data">
<input type="file" size="70" name="file" /><br />
<INPUT type="submit" value="Submit">
</FORM>
和servlet的是這樣的:
protected void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
DiskFileUpload upload = new DiskFileUpload();
upload.setSizeMax(10000000);// 10 Mo
List items;
try {
items = upload.parseRequest(request);
Iterator itr = items.iterator();
while(itr.hasNext()) {
FileItem item = (FileItem) itr.next();
}
} catch (FileUploadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
我的目錄 「項」 始終是空的!