eclipse運(yùn)行Tomcat8源碼訪問jsp報(bào)錯
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)
根據(jù)debug發(fā)現(xiàn)是JspFactory.getDefaultFactory()返回null導(dǎo)致的,而setDefaultFactory是在JasperInitializer內(nèi)的靜態(tài)塊內(nèi)調(diào)用的雀哨,一個解決辦法就是講JasperInitializer內(nèi)的靜態(tài)塊代碼移入Bootstrap內(nèi),這樣就可以正確的訪問jsp了膊夹。