SpringBoot嵌入式Tomcat JSPServlet选项

编程入门 行业动态 更新时间:2024-10-28 10:29:05
本文介绍了SpringBoot嵌入式Tomcat JSPServlet选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

设置JSPServlet的配置选项(如checkInterval,keepgeneration,modificationTestInterval等)的首选方法是什么?我之所以要更改它,是因为JSP编译存在一些奇怪的问题.我们正在使用可执行文件打包,并将'server.tomcat.basedir'属性设置为指向本地可访问的文件夹.生成的jsp java源文件和类文件显示的修改日期为1970年1月14日.在Windows资源管理器中,修改仅显示为空.在linux上,我们触摸了所有文件.但是,只要再次访问jsp文件,修改日期就可以追溯到1970年.我们怀疑这是否会导致每次访问jsp文件时都会对其进行编译,从而减慢了运行速度.但是,重新编译似乎只发生在linux环境中.有没有人遇到过这个问题?我们的环境:Spring Boot 1.2.2.BUILD-SNAPSHOT,Tomcat 8,JDK 1.8_025.

What is the preferred way to set the configuration options for JSPServlet like checkInterval, keepgenerated, modificationTestInterval etc? The reason I am trying to alter it is because of some strange issues with JSP Compilations. We are using executable war packaging and setting the 'server.tomcat.basedir' property to point to a locally accessible folder. The generated jsp java source and class files shows modification date as Jan 14 1970. In windows explorer, the modification just shows up as empty. On linux, we did a touch on all the files. But as soon as the jsp file is accessed again, the modification date goes back to 1970. We doubt that this is causing the jsp files to be compiled every time it is accessed and thus slowing things down. However the recompilation only seems to happen in linux environment. Has anyone experienced this problem? Our environment : Spring Boot 1.2.2.BUILD-SNAPSHOT, Tomcat 8, JDK 1.8_025.

推荐答案

您可以使用EmbeddedServletContainerCustomizer @Bean查找JSP servlet并配置其init参数.例如,在您的主要@Configuration类中:

You can use an EmbeddedServletContainerCustomizer @Bean to look up the JSP servlet and configure its init parameters. For example, in your main @Configuration class:

@Bean public EmbeddedServletContainerCustomizer customizer() { return new EmbeddedServletContainerCustomizer() { @Override public void customize(ConfigurableEmbeddedServletContainer container) { if (container instanceof TomcatEmbeddedServletContainerFactory) { customizeTomcat((TomcatEmbeddedServletContainerFactory) container); } } private void customizeTomcat(TomcatEmbeddedServletContainerFactory tomcat) { tomcat.addContextCustomizers(new TomcatContextCustomizer() { @Override public void customize(Context context) { Wrapper jsp = (Wrapper) context.findChild("jsp"); jsp.addInitParameter("modificationTestInterval", "10"); } }); } }; }

更多推荐

SpringBoot嵌入式Tomcat JSPServlet选项

本文发布于:2023-10-30 11:16:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1542703.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:嵌入式   选项   SpringBoot   JSPServlet   Tomcat

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!