我收到以下错误,因为行System.out.println(sendURL.substring(0, sendURL.lastIndexOf("/")));
sendURL不为null,它有值。任何人都可以帮我解决这个问题。提前谢谢!
消息
description服务器遇到内部错误(),导致无法完成此请求。
异常
org.apache.jasper.JasperException: An exception occurred processing JSP page /jsp/authenticate.jsp at line 47
44: config = getServletConfig();
45: String localStoreurl=application.getInitParameter("localstorefile");
46: String domain=application.getInitParameter("domain");
47: System.out.println(sendURL.substring(0, sendURL.lastIndexOf("/")));
48: %>
49: <html xmlns="http://www.w3.org/1999/xhtml">
50: <head>
Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:519)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:428)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause java.lang.NullPointerException
org.apache.jsp.jsp.authenticate_jsp._jspService(authenticate_jsp.java:103)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.30 logs.
Apache Tomcat / 6.0.30
答案 0 :(得分:0)
我认为它正在抛出IndexOutOfBoundsException,如果beginIndex为负数,或者endIndex大于此String对象的长度,或者beginIndex大于endIndex,则抛出它。阅读documentation。
在您的情况下,如果字符串不包含任何“ / ”,则beginIndex将大于endIndex。
您应该在调用subString方法之前检查这些条件。
答案 1 :(得分:0)
请检查sendURL
变量,可能是值为null。