hiii大家......我正在netbeans ide上做我的项目,为数据库创建一个post web服务器。我在文件上传方面遇到了一些问题..我正在从高级休息客户端发送数据以及文件... bt发送500错误...它不接受request.getParameter(“我从休息客户端提供的数据”) ....我的代码是......
else if (action.equalsIgnoreCase("fileUpload")) {
String userId =request.getParameter("userId");
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if (!isMultipart) {
} else {
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List items = null;
try {
items = upload.parseRequest(request);
} catch (FileUploadException e) {
e.printStackTrace();
}
Iterator itr = items.iterator();
while (itr.hasNext()) {
FileItem item = (FileItem) itr.next();
if (item.isFormField()) {
}
else {
try {
String itemName = item.getName();
System.out.println("FILE PATH " + getServletContext().getRealPath("/"));
File savedFile = new File(getServletContext().getRealPath("/") + "uploadedFiles/" + itemName);
item.write(savedFile);
String str = "build-web-uploadedFiles-" + itemName + "";
dao.addFile(userId, str);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}