当前位置: 代码迷 >> Java Web开发 >> jsp向sevlet传值出错。解决思路
  详细解决方案

jsp向sevlet传值出错。解决思路

热度:314   发布时间:2016-04-17 00:53:31.0
jsp向sevlet传值出错。。。
错误如下:
2011-10-9 21:40:29 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet addfriendServlet threw exception
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:687)
at org.apache.jasper.compiler.JspUtil.makeJavaIdentifier(JspUtil.java:962)
at org.apache.jasper.JspCompilationContext.getServletClassName(JspCompilationContext.java:371)
at org.apache.jasper.JspCompilationContext.getServletJavaFileName(JspCompilationContext.java:470)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:144)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:315)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
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:191)
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:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
-----------------------------------------
这是什么缘故?

------解决方案--------------------
addfriendServlet --> java.lang.StringIndexOutOfBoundsException: String index out of range: 0

下标越界
------解决方案--------------------
这好像是个数组越界的异常吧。你贴你的原代码吧。
------解决方案--------------------
在addfriendServlet这个servlet中
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
即是你对某个字符串调用charAt()方法的时候下标越界了
------解决方案--------------------
探讨
addfriendServlet --> java.lang.StringIndexOutOfBoundsException: String index out of range: 0

下标越界

------解决方案--------------------
你把源码贴出来下咯。。。
------解决方案--------------------
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
很简单,你的字符串是空字符串,而你使用了charAt(0)来访问第0个字符,结果越界。
------解决方案--------------------
晕啊,错误异常不都报出来了吗?
------解决方案--------------------
java.lang.StringIndexOutOfBoundsException: String index out of range: 0

上面的人说的很明白了吧