我將多個Excel文件上傳到服務器。對於文件,我使用CommonsMultiPartFile
類。我的問題是,當我嘗試處理文件上傳類似用Spring上傳文件
File KUStiedosto = new File(form.getKUS().getOriginalFilename());
form.getKUS().transferTo(KUStiedosto);
Workbook KUStk = Workbook.getWorkbook(KUStiedosto);
Sheet KUSl = KUStk.getSheet(0);
for (int r = 7; r < KUSl.getRows() - 1; r++) {
我得到
java.io.FileNotFoundException: 2601401KUS1007.xls (Access is denied)
java.io.FileOutputStream.open(Native Method)
java.io.FileOutputStream.<init>(FileOutputStream.java:179)
java.io.FileOutputStream.<init>(FileOutputStream.java:131)
org.apache.commons.fileupload.disk.DiskFileItem.write(DiskFileItem.java:423)
org.springframework.web.multipart.commons.CommonsMultipartFile.transferTo(CommonsMultipartFile.java:137)
fi.utu.seurantaraporttisuodatin.service.Kustannusraportti.calculateKUS(Kustannusraportti.java:27)
fi.utu.seurantaraporttisuodatin.service.Raportti.createReportContext(Raportti.java:424)
fi.utu.seurantaraporttisuodatin.controller.FormController.onSubmit(FormController.java:68)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:174)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:421)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:409)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
我有什麼用我的服務器的權利做的還是有別的東西嗎?我正在使用Netbeans和附加的Tomcat服務器。
您是否找到任何解決方案? – 2015-05-25 02:47:21