为了账号安全,请及时绑定邮箱和手机立即绑定

有异常,求解决

五月 15, 2017 10:38:46 上午 org.apache.catalina.core.StandardWrapperValve invoke

严重: Servlet.service() for servlet [UploadServlet] in context with path [/scxz] threw exception

java.lang.StringIndexOutOfBoundsException: String index out of range: -1

at java.lang.String.substring(Unknown Source)

at com.imooc.servlet.UploadServlet.doPost(UploadServlet.java:46)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)

at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)

at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)

at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)

at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)


正在回答

1 回答

需要有个地方设置 request.setAttribute("vector" , vector对象);
然后才能取值,一般是在 session 中 setAttribute 和 getAttribute.
request.getAttribute("vector"); 没有取到 vector  值,  
可以改成 if(  request.getAttribute("vector") != null) {
                          vector = (Vector) request.getAttribute("vector");

                              Vector news = (Vector) vector.get(0);
Vector hot = (Vector) vector.get(1);
Vector placard = (Vector) vector.get(2);

 }

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Java中的文件上传下载
  • 参与学习       77393    人
  • 解答问题       337    个

由简入深,轻松实现文件上传下载功能及相关框架的使用

进入课程

有异常,求解决

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信