CommonUpload上传文件为什么总是在根目录,该如何处理

CommonUpload上传文件为什么总是在根目录
关键代码:
factory.setRepository(new File(request.getSession().getServletContext().getRealPath("/") + "images"));

上传的文件总是根目录下,就偏偏不在images的路径下,很是纠结啊,求高手解救!!!!!

------解决方案--------------------
String path2 = getServletContext().getRealPath("upload");
System.out.println(path2);
File file = new File(path2 + "/" + filename2);
试试看
------解决方案--------------------
api使用出错了
setRepository(File repository)
Sets the directory used to temporarily store files that are larger than the configured size threshold.
这个接口从描述上来理解,只是设置的临时存放路径的,你需要
// Create a factory for disk-based file items
FileItemFactory factory = new DiskFileItemFactory();
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
// Parse the request
List /* FileItem */ items = upload.parseRequest(request);
// Process the uploaded items
Iterator iter = items.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();

if (item.isFormField()) {
processFormField(item);
} else {
processUploadedFile(item);
}
}
// Process a file upload
if (writeToFile) {
File uploadedFile = new File(...);......................这才是你需要设置的最终路径
item.write(uploadedFile);
} else {
InputStream uploadedStream = item.getInputStream();
...
uploadedStream.close();
}