8
回答
jfianl上传文件报错
华为云实践训练营,热门技术免费实践!>>>   


[ERROR]-[Thread: http-8080-1]-[com.jfinal.core.ActionHandler.handle()]: /blog/uploadFile

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:61)
at com.demo.blog.BlogInterceptor.intercept(BlogInterceptor.java:18)
at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:51)
at com.jfinal.core.ActionHandler.handle(ActionHandler.java:73)
at com.jfinal.ext.handler.ContextPathHandler.handle(ContextPathHandler.java:47)
at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:55)
... 17 more
Caused by: java.lang.NoClassDefFoundError: com/oreilly/servlet/multipart/FileRenamePolicy
at com.jfinal.core.Controller.getFiles(Controller.java:684)
at com.jfinal.core.Controller.getFile(Controller.java:696)
at com.demo.blog.BlogController.uploadFile(BlogController.java:60)
... 22 more
Caused by: java.lang.ClassNotFoundException: com.oreilly.servlet.multipart.FileRenamePolicy
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

... 25 more

服务器端代码如下:

   public void uploadFile(){
  System.out.println("----------begin upload file------------");
  String  saveDirectory="c:\\";
  UploadFile  uf=getFile("pFile");    

  System.out.println("----------end upload file------------");
//   System.out.println(uf.getFileName());
  
   }

前端uploadFile.jsp 如下 :

  <form id="form1" action="uploadFile" method="post" enctype="multipart/form-data" >
    <input type="file" id="idFile" name="pFile"></input>
    <input type="submit"  value="上传">
  </form>


举报
andying
发帖于4年前 8回/4K+阅
顶部