user.add(username);
request.getRequestDispatcher("/add_success.jsp").forward(request, response);
String requestURI = request.getRequestURI();
String path = requestURI.substring(requestURI.indexOf("/", 1), requestURI.indexOf(".")); //这行有错!
System.out.println("path=" + path);
type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception java.lang.StringIndexOutOfBoundsException: String index out of range: -11
java.lang.String.substring(String.java:1938)
com.TestTest.TestServlet.doPost(TestServlet.java:27)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
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.33 logs.
request.getRequestDispatcher("/add_success.jsp").forward(request, response);
String requestURI = request.getRequestURI();
String path = requestURI.substring(requestURI.indexOf("/", 1), requestURI.indexOf(".")); //这行有错!
System.out.println("path=" + path);
type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception java.lang.StringIndexOutOfBoundsException: String index out of range: -11
java.lang.String.substring(String.java:1938)
com.TestTest.TestServlet.doPost(TestServlet.java:27)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
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.33 logs.
试试这样
requestURI.indexOf("."));
System.out.println("path=" + path);
String path = requestURI.substring(requestURI.indexOf("/", 1), requestURI.indexOf(".")-requestURI.indexOf("/", 1),);
这样就对了