0

我们一直在使用 ExtJS 小部件“多个文件上传”来一次上传多个文件。UI 方面一切正常,但是当我们在 Spring 的操作中遇到错误时。我想知道如何在 Java 中检索行 POST 数据?

用户界面: ExtJS

控制器:

   @RequestMapping(value = "views/upload.action", method = RequestMethod.POST)
public @ResponseBody String create(FileUploadBean uploadItem, BindingResult result) throws IOException{
    ExtJSFormResult extjsFormResult = new ExtJSFormResult();
    File file = new File(uploadItem.getFile().getOriginalFilename()); 
    uploadItem.getFile().transferTo(file);
    LOGGER.info("file is : "+ file);
    copyFile(file, uploadItem);
    try{
        dis.close();
        fis.close();
    }
    catch(IOException ioe){
        ioe.printStackTrace();
        LOGGER.error("IOException"+ ioe.getMessage());
    }catch(MultipartException ml){ml.printStackTrace();}

  if (result.hasErrors()){
        for(ObjectError error : result.getAllErrors()){
            LOGGER.info("Error: " + error.getCode() +  " - " + error.getDefaultMessage());
        }
        //set extjs return - error
        extjsFormResult.setSuccess(false);
        return extjsFormResult.toString();
    }
    //set extjs return - sucsess
    extjsFormResult.setSuccess(true);
    return extjsFormResult.toString();
}

堆栈跟踪:

May 30, 2012 6:47:51 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [appServlet] in context with path [/Login] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause java.lang.NullPointerException at com.mpm.common.controller.FileUploadController.create(FileUploadController.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:585)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:279)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

谢谢卡皮尔

4

0 回答 0