我們知道,需要運行shtml,必須在web伺服器上配置好ssi。
下面是ssi在tomcat5.*上的設定方法:
開啟tomcat設定檔:conf/web.xml:
1.去掉下面servlet前的註解
/* <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>
<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>
2、去掉servlet映射的註解
/*<servlet-mapping>
<servlet-name>ssi</servlet-name>
<url-pattern>*.shtml</url-pattern>
</servlet-mapping>
*/
改成
<servlet-mapping>
<servlet-name>ssi</servlet-name>
<url-pattern>*.shtml</url-pattern>
</servlet-mapping>
3、在serverlib目錄中找到servlets-ssi.renametojar文件,改成servlets-ssi.jar
4、重啟tomcat
5、新建一個shtml文件測試一下
<HTML>
<HEAD>
<TITLE>shtml測試</TITLE>
</HEAD>
<BODY>
<!–#echo var=”DATE_LOCAL” –>
<!–#include virtual=”hello.jsp”–>
</BODY>
</HTML>
執行ok! ! !