protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter( );
if(ServletFileUpload.isMultipartContent(request)){
try {
List<FileItem> multiparts = new ServletFileUpload(
new DiskFileItemFactory()).parseRequest(request);
for(FileItem item : multiparts){
if(!item.isFormField()){
String name = new File(item.getName()).getName();
item.write( new File(UPLOAD_DIRECTORY + File.separator + name));
}
}
} catch (Exception ex) {
out.println("File Upload Failed due to " + ex);
}
}
答案 0 :(得分:0)
你有没有尝试过:
out.println("File Upload Failed due to " + ex.getMessage());
或
out.println("File Upload Failed due to " + ex.printStackTrace());
答案 1 :(得分:0)
尝试使用doGet。
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.print("hey");
}