• servlet上传文件报错(二)


    1、具体报错如下:

    java.io.FileNotFoundException: D:MyEclipseworkspaceFileUploadWebRootupload (拒绝访问。)
    	at java.io.FileOutputStream.open(Native Method)
    	at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
    	at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
    	at com.you.file.servlet.FileUploadServlet.doPost(FileUploadServlet.java:68)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
    	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    	at java.lang.Thread.run(Thread.java:619)
    

        控制台还出现乱码




    2、错误原因

    (1)出现乱码的原因:上传的文件中包含图

    (2)拒绝访问的原因:因为catch中抛出异常,提示拒绝访问


    3、解决办法

    catch (Exception e) 
    {
        //e.printStackTrace();
    }



  • 相关阅读:
    ASP.NET的票据工具类FormsAuthenticationTicket
    FormsAuthenticationTicket学习笔记
    FormsAuthentication与Session超时时间不一的解决方法
    asp.net mvc 从数据库中读取图片的实现代码
    ASP.NET下载远程图片保存到本地的方法、保存抓取远程图片
    获取客户端的IP地址
    C#实现DNS解析服务
    Linux下安装Nginx详细图解教程
    手动配置Ubuntu Linux系列3-缺省网关和主机名
    web运维第一篇:nginx配置文件详解笔记
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13315174.html
Copyright © 2020-2023  润新知