47.4. SSI

简介:

编辑 context.xml 文件,增加 privileged="true 属性

		
# vim /srv/apache-tomcat/conf/context.xml

<Context privileged="true">

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>

    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->

    <!-- Uncomment this to enable Comet connection tacking (provides events
         on session expiration as well as webapp lifecycle) -->
    <!--
    <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
    -->

</Context>
		
		

编辑 web.xml 文件,取消下面的注释

		
# vim /srv/apache-tomcat/conf/web.xml	
	
    <servlet>
        <servlet-name>ssi</servlet-name>
        <servlet-class>
          org.apache.catalina.ssi.SSIServlet
        </servlet-class>
        <init-param>
          <param-name>buffered</param-name>
          <param-value>1</param-value>
        </init-param>
        <init-param>
          <param-name>debug</param-name>
          <param-value>0</param-value>
        </init-param>
        <init-param>
          <param-name>expires</param-name>
          <param-value>666</param-value>
        </init-param>
        <init-param>
          <param-name>isVirtualWebappRelative</param-name>
          <param-value>false</param-value>
        </init-param>
        <load-on-startup>4</load-on-startup>
    </servlet>
		
		

配置需要SSI处理的文件

		
# vim  /srv/apache-tomcat/webapps/ROOT/WEB-INF/web.xml

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                      http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  version="3.0"
  metadata-complete="true">

  <display-name>Welcome to Tomcat</display-name>
  <description>
     Welcome to Tomcat
  </description>


	<servlet-mapping>  
        <servlet-name>ssi</servlet-name>  
        <url-pattern>*.shtml</url-pattern>  
        <url-pattern>*.html</url-pattern>  
	</servlet-mapping>  


</web-app>
		
		

重新启动Tomcat

创建测试文件

		
# vim webapps/ROOT/index.html

<!--#echo var="DATE_LOCAL" -->
		
		

验证测试结果

		
# curl http://224.25.22.70:8080/
Tuesday, 03-Nov-2015 09:32:30 HKT
		
		




原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

目录
相关文章
|
前端开发 应用服务中间件 程序员
nginx中SSI问题的研究
nginx中SSI问题的研究
180 0
|
PHP
ssi
SSI (Server Side Include)的 html 文件扩展名 (.shtml), 通常称为"服务器端嵌入"或者叫"服务器端包含" 说白了就是类似其他语言如 PHP include 引入其他文件,SSI 是通过配置服务器,一个静态 html 文件引入另一个 html 文件的功能。
1488 0
|
Java Apache 应用服务中间件
|
Java 开发工具 应用服务中间件