eclipse运行Tomcat8源码访问jsp报错
Servlet.service() for servlet [jsp] in context with path [] threw exception [Unable to compile class for JSP] with root cause
java.lang.NullPointerException
at org.apache.jasper.compiler.Validator$ValidateVisitor.<init>(Validator.java:517)
at org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1854)
根据debug发现是JspFactory.getDefaultFactory()返回null导致的,而setDefaultFactory是在JasperInitializer内的静态块内调用的,一个解决办法就是讲JasperInitializer内的静态块代码移入Bootstrap内,这样就可以正确的访问jsp了。
网友评论