0
簡歷上傳/下載java中如何在servlet/jsp中將整個簡歷存儲在mysql數據庫中?
我想我的簡歷存儲MySQL數據庫中,然後下載在我的系統。簡歷大小高達5 MB。怎麼做??
當前我保存數據庫路徑並恢復到文件夾中。
簡歷上傳/下載java中如何在servlet/jsp中將整個簡歷存儲在mysql數據庫中?
我想我的簡歷存儲MySQL數據庫中,然後下載在我的系統。簡歷大小高達5 MB。怎麼做??
當前我保存數據庫路徑並恢復到文件夾中。
請參閱ServletFileUpload()
由servlet技術提供,下面是顯示客戶端提交的文件讀取的一段代碼。
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request);
for (FileItem item : items) {
if (item.isFormField()) {
// Process regular form field (input type="text|radio|checkbox|etc", select, etc).
String fieldname = item.getFieldName();
String fieldvalue = item.getString();
// ... (do your job here)
} else {
// Process form file field (input type="file").
String fieldname = item.getFieldName();
String filename = FilenameUtils.getName(item.getName());
InputStream filecontent = item.getInputStream();
// store your file in mysql db
}
}
} catch (FileUploadException e) {
throw new ServletException("Cannot read the file", e);
}
// ...
}
的servlet是JSP的祖先,因此,你可以在JSP中使用同樣的方法也。
你的簡歷格式是什麼?您始終可以將它們存儲爲斑點。 –
它在.doc,.docx,.pdf,.txt –
檢查此..它可能會幫助你一點點http://stackoverflow.com/questions/9430008/inserting-blob-data-in-java-using-preparedstatement – Naren