修改JSP页面为什么不用重启Tomcat

JSP->servlet->.clsss

JSP最终要转换为class文件,为什么tomcat在修改java代码的必须先重启tomcat,反而JSP不用。?

在Tomcat的Conf/web.xml文件中,可以对Tomcat的这种对JSP修改的机制进行修改。

 

这是因为Tomcat对JSP进入了侦听,如果有修改,就会重新翻译成Servlet并最终编译成Class文件,替换掉原JSP页面对应的Class文件。Tomcat的内部机制是可以让这种Class文件立即生效的。而普通的Class文件修改后,不能立即生效。

 

 

Java代码  收藏代码
  1. <!--   modificationTestInterval                                           -->  
  2. <!--                       Causes a JSP (and its dependent files) to not  -->  
  3. <!--                       be checked for modification during the         -->  
  4. <!--                       specified time interval (in seconds) from the  -->  
  5. <!--                       last time the JSP was checked for              -->  
  6. <!--                       modification. A value of 0 will cause the JSP  -->  
  7. <!--                       to be checked on every access.                 -->  
  8. <!--                       Used in development mode only. [4]             -->  

 

在“development”(开发模式)下,可以使用modificationTestInterval来设置Tomcat检查JSP更新的时间间隔,单位为秒,默认4秒

Java代码  收藏代码
  1. <!--   checkInterval       If development is false and checkInterval is   -->  
  2. <!--                       greater than zero, background compilations are -->  
  3. <!--                       enabled. checkInterval is the time in seconds  -->  
  4. <!--                       between checks to see if a JSP page (and its   -->  
  5. <!--                       dependent files) needs to  be recompiled. [0]  -->  

 

在非“development”模式下,使用checkInterval来设置Tomcat检查JSP更新的时间间隔,单位为秒,默认为不检查。

 

对于上面提到的“development”模式,也是在web.xml文件中配置的,如下

Java代码  收藏代码
  1. <!--   development         Is Jasper used in development mode? If true,   -->  
  2. <!--                       the frequency at which JSPs are checked for    -->  
  3. <!--                       modification may be specified via the          -->  
  4. <!--                       modificationTestInterval parameter. [true]     -->  

默认情况下Tomcat使用“development” 模式。

 

posted @ 2015-08-05 21:21  Hallen-Liu  阅读(939)  评论(0编辑  收藏  举报