不明报错
最近做突然有这这样的错误,真不知怎么会是,空指针?到底是哪里空指针呢,现在他要就是500错误,要就是404错误,真不知是哪出问题,404报错
HTTP Status 404 - Servlet ArticleServlet is not available
500报错
javax.servlet.ServletException: Error instantiating servlet class yuyi.servlet.ArticleServlet
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:743)
org.apache.tomcat.(PoolTcpEndpoint.java:527)
org.apache.tomcat.(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:619)
root cause
java.lang.NullPointerException
javax.servlet.GenericServlet.getServletContext(GenericServlet.java:159)
yuyi.servlet.ArticleServlet.<init>(ArticleServlet.java:36)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
java.lang.Class.newInstance0(Class.java:355)
java.lang.Class.newInstance(Class.java:308)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:743)
org.apache.tomcat.(PoolTcpEndpoint.java:527)
org.apache.tomcat.(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:619)
这错误我找到啦,错误是我讲上传文件的路径设置成了全局变量,为什么我这样设置就会有错误呢?
就是这句话: String Path = this.getServletContext().getRealPath("/")+ "upload//File";
[ 本帖最后由 lovemm 于 2010-10-21 15:59 编辑 ]