本文主要是介绍tomcat ssi配置 支持html,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.官方参考文档地址:
http://httpd.apache.org/docs/current/howto/ssi.html#basicssidirectives
https://tomcat.apache.org/tomcat-7.0-doc/ssi-howto.html
2.配置步骤
(1)修改tomcat根目录下的conf文件夹中的context.xml,修改如下:
Xml代码
- <Context privileged="true">
- <!-- Default set of monitored resources -->
- <WatchedResource>WEB-INF/web.xml</WatchedResource>
- </Context>
即在Context 中增加privileged="true"
(2)修改tomcat根目录下的conf文件夹中的web.xml,将SSI的Servlet的配置取消注释,并增加编码配置,否则可能出现乱码
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>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>
- <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 Servlet的mapping注释,增加*.html,因为我们是在html中引入shtml的,如果不配置*.html,则tomcat不会处理html中的ssi指令
Xml代码
- <servlet-mapping>
- <servlet-name>ssi</servlet-name>
- <url-pattern>*.shtml</url-pattern>
- <url-pattern>*.html</url-pattern>
- </servlet-mapping>
这篇关于tomcat ssi配置 支持html的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!