Tomcat7开启SSI功能

1.官方参考文档地址:
2.配置步骤
(1)修改tomcat根目录下的conf文件夹中的context.xml,修改如下:
Xml代码  Tomcat7开启SSI功能
  1. <Context privileged="true">  
  2.     <!-- Default set of monitored resources -->  
  3.     <WatchedResource>WEB-INF/web.xml</WatchedResource>  
  4. </Context>  
 即在Context 中增加privileged="true"
(2)修改tomcat根目录下的conf文件夹中的web.xml,将SSI的Servlet的配置取消注释,并增加编码配置,否则可能出现乱码
Xml代码  Tomcat7开启SSI功能
  1. <servlet>  
  2.         <servlet-name>ssi</servlet-name>  
  3.         <servlet-class>  
  4.           org.apache.catalina.ssi.SSIServlet  
  5.         </servlet-class>  
  6.         <init-param>  
  7.           <param-name>buffered</param-name>  
  8.           <param-value>1</param-value>  
  9.         </init-param>  
  10.         <init-param>  
  11.           <param-name>inputEncoding</param-name>  
  12.           <param-value>UTF-8</param-value>  
  13.         </init-param>  
  14.         <init-param>  
  15.           <param-name>outputEncoding</param-name>  
  16.           <param-value>UTF-8</param-value>  
  17.         </init-param>  
  18.         <init-param>  
  19.           <param-name>debug</param-name>  
  20.           <param-value>0</param-value>  
  21.         </init-param>  
  22.         <init-param>  
  23.           <param-name>expires</param-name>  
  24.           <param-value>666</param-value>  
  25.         </init-param>  
  26.         <init-param>  
  27.           <param-name>isVirtualWebappRelative</param-name>  
  28.           <param-value>false</param-value>  
  29.         </init-param>  
  30.         <load-on-startup>4</load-on-startup>  
  31.     </servlet>  
 取消SSI Servlet的mapping注释,增加*.html,因为我们是在html中引入shtml的,如果不配置*.html,则tomcat不会处理html中的ssi指令
Xml代码  Tomcat7开启SSI功能
  1. <servlet-mapping>  
  2.         <servlet-name>ssi</servlet-name>  
  3.         <url-pattern>*.shtml</url-pattern>  
  4.         <url-pattern>*.html</url-pattern>  
  5.     </servlet-mapping>  

相关推荐