org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to load class for JSP org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:156) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
原因: Tomcat对jsp的处理是由一个JspServlet来完成的,当tomcat启动时,会为每一个context创建jsp工作目录(work dir),存放地为 CATALINA_HOME/work/Catalina/HOST_NAME/CONTEXT_NAME,context编译jsp所需要的参数也随之初始化,加载jsp class的base path也已经潜在初始化,是一个File对象,它将在随后URLClassLoader加载jsp class时作为一个resource url,下面是部分代码: org.apache.jasper.JspCompilationContext.java 初始化 JspLoader
其中baseUrl是这样得到的