Java 在tomcat嵌入jasper中禁用JSP池
我有一个使用嵌入式tomcat/jasper的web应用程序,其代码配置如下:Java 在tomcat嵌入jasper中禁用JSP池,java,jsp,tomcat,jsp-tags,embedded-tomcat-8,Java,Jsp,Tomcat,Jsp Tags,Embedded Tomcat 8,我有一个使用嵌入式tomcat/jasper的web应用程序,其代码配置如下: public class Main { public static void main(String[] args) throws Exception { String webappDirLocation = "src/main/webapp/"; Tomcat tomcat = new Tomcat(); // The port that we shoul
public class Main {
public static void main(String[] args) throws Exception {
String webappDirLocation = "src/main/webapp/";
Tomcat tomcat = new Tomcat();
// The port that we should run on can be set into an environment variable
// Look for that variable and default to 8080 if it isn't there.
String webPort = System.getenv("PORT");
if (webPort == null || webPort.isEmpty()) {
webPort = "8080";
}
tomcat.setPort(Integer.valueOf(webPort));
StandardContext ctx = (StandardContext) tomcat.addWebapp("", new File(webappDirLocation).getAbsolutePath());
File additionWebInfClasses = new File("target/classes");
WebResourceRoot resources = new StandardRoot(ctx);
resources.addPreResources(
new DirResourceSet(resources, "/WEB-INF/classes", additionWebInfClasses.getAbsolutePath(), "/"));
ctx.setResources(resources);
ctx.setDelegate(true);
tomcat.start();
tomcat.getServer().await();
}
}
我有一些遗留JSP标记库,需要在Jasper中关闭JSP池
xml文件没有设置jasperservlet(只有处理请求映射的定制servlet),所有JSP/taglib都可以正常运行(除了池问题)。如何使用上面的“main”函数,利用嵌入的Tomcat,将“enablePooling”jasper设置设置为false?如何
Wrapper-jspServlet=context.createWrapper();
setName(“jsp”);
setServlet类(“org.apache.jasper.servlet.jspServlet”);
addInitParameter(“enablePooling”、“false”);
...
ctx.addChild(jspServlet);