1.SSI是Server Side Includes 的缩写,是嵌入到HTML页面的一组指令的集合。在返回请求的页面(包含SSI指令前),服务器会处理这些指令,并用处理的结果替换指令,然后把页面返回。这样就允许在HTML页面中添加动态产生的内容。
2.配置:tomcat6
在在conf包下web.xml中打开注释掉的ssi servlet和servlet-mapping
<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>0</param-value> </init-param> <load-on-startup>4</load-on-startup> </servlet> <servlet-mapping> <servlet-name>ssi</servlet-name> <url-pattern>*.shtml</url-pattern> </servlet-mapping>
在conf包下context.xml中添加配置
<Context privileged = "true">
页面显示乱码解决在conf包下web.xml中ssi servlet配置中添加:
注:其中的utf-8应该和页面的编码方式一样
<init-param> <param-name>inputEncoding</param-name> <param-value>utf-8</param-value> </init-param> <init-param> <param-name>outputEncoding</param-name> <param-value>utf-8</param-value> </init-param>
引入文件方式:
<!--#include file="a.html" --> <!--#include virtual="b.shtml" -->
本文参考:http://www.codesky.net/article/201107/148798.html
时间: 2024-10-09 11:46:18