java Jsp 编译不是用 jboss 即时编译的

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5786610/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 12:45:12  来源:igfitidea点击:

Jsp compilation not on the fly with jboss

javajspjbosscompilation

提问by jsebfranck

It is possible to compile jsp during the application deployment or during jboss startup? Usually jsp are compiled on the fly but it would be convenient if the compilation was done before...

是否可以在应用程序部署或jboss启动期间编译jsp?通常jsp是即时编译的,但如果编译之前完成会很方便......

I read it is not possible anymore to precompile jsp wit jee6... That's why libraries are not supplied with jboss 6. Is there another way to do that?

我读到不再可能用 jee6 预编译 jsp ... 这就是为什么 jboss 6 不提供库的原因。还有其他方法可以做到这一点吗?

Thanks in advance!

提前致谢!

回答by Heiko Rupp

You need to modify $server/deploy/jbossweb.sar/web.xml and have the jsp servlet include a positive check value

您需要修改 $server/deploy/jbossweb.sar/web.xml 并让 jsp servlet 包含一个肯定的检查值

   <servlet>
      <servlet-name>jsp</servlet-name>
      <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
      <init-param>
         <param-name>checkInterval</param-name>
         <param-value>1</param-value>
      </init-param>

See the docs above the tag:

请参阅标签上方的文档:

   <!--   checkInterval       If development is false and checkInterval is   -->
   <!--                       greater than zero, background compilations are -->
   <!--                       enabled. checkInterval is the time in seconds  -->
   <!--                       between checks to see if a JSP page needs to   -->
   <!--                       be recompiled. [0]                             -->
   <!--                                                                      -->
   <!--   modificationTestInterval                                           -->
   <!--                       Causes a JSP (and its dependent files) to not  -->
   <!--                       be checked for modification during the         -->
   <!--                       specified time interval (in seconds) from the  -->
   <!--                       last time the JSP was checked for              -->
   <!--                       modification. A value of 0 will cause the JSP  -->
   <!--                       to be checked on every access.                 -->
   <!--                       Used in development mode only. [4]             -->

回答by dabuda

I was facing similar issue in my development environment. Thanks to Heiko's answer, I tried another option by setting development and modificationTestInterval as follows in the web.xml.

我在我的开发环境中遇到了类似的问题。感谢 Heiko 的回答,我尝试了另一种选择,在 web.xml 中设置 development 和 modifyTestInterval 如下。

  <init-param>
     <param-name>development</param-name>
     <param-value>true</param-value>
  </init-param>
  <init-param>
     <param-name>modificationTestInterval</param-name>
     <param-value>0</param-value>
  </init-param>

Now I'm able to modify the JSPs in '$JBOSS_HOME\server\default\tmp\%random_crap%\war-1.0.war\WEB-INF\jsp' and have it recompile without restarting JBOSS.

现在我可以修改 '$JBOSS_HOME\server\default\tmp\%random_crap%\war-1.0.war\WEB-INF\jsp' 中的 JSP,并在不重新启动 JBOSS 的情况下重新编译它。

Also want to note this was not required in JBoss 4.3, so for developers upgrading from 4.3 to 5.2 just be aware of this extra step.

还要注意这在 JBoss 4.3 中不是必需的,因此对于从 4.3 升级到 5.2 的开发人员,请注意这个额外的步骤。

回答by Gonzalo

By default, last versions of JBoss like EAP 6 precompile all the JSP and use that coompiled version untill ther is a full redeployment of the aplication.

默认情况下,JBoss 的最新版本(如 EAP 6)预编译所有 JSP 并使用该编译版本,直到完全重新部署应用程序。

You can use 'Keep-Generated' and 'Check-Interval' parameters to modify that behaviour, so that JBoss recompile JSPs any time they are updated. You have a detail description of those parameters at:

您可以使用“Keep-Generated”和“Check-Interval”参数来修改该行为,以便 JBoss 在 JSP 更新时重新编译它们。您可以在以下位置获得这些参数的详细说明:

https://access.redhat.com/site/documentation/en-US/JBoss_Enterprise_Application_Platform/6.1/html/Administration_and_Configuration_Guide/chap-Web_Subsystem.html

https://access.redhat.com/site/documentation/en-US/JBoss_Enterprise_Application_Platform/6.1/html/Administration_and_Configuration_Guide/chap-Web_Subsystem.html

Regards, Gonzalo

问候, 贡萨洛