要在我们的servlet中以编程方式创建页面上下文,请执行以下操作:
JspFactory factory = JspFactory.getDefaultFactory();
PageContext pageContext = factory.getPageContext(this, request, response,
"404", true, 4096, false);
这在tomcat和dev gae环境下正常工作。但是,将应用程序部署到实时环境中时,JspFactory.getDefaultFactory()返回null。
web.xml的标题具有以下内容:
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
有谁知道如何以编程方式在Google App Engine上创建PageContext?
最佳答案
在某处阅读。 Google APP Engine似乎在后面使用了Tomcat,这看起来像是个bug。解决方法是将默认工厂设置为Class.forName("org.apache.jasper.compiler.JspRuntimeContext");