Tomcat7下配置SSI(解决中文乱码问题)
web.xml 取消SSI注释ssiorg.apache.catalina.ssi.SSIServletbuffered1debug0expires666isVirtualWebappRelative0inputEncodingutf-8outputEncodingutf-84ssi*.shtml*第一段中需
·
web.xml 取消SSI注释
<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>
<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>
<load-on-startup>4</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ssi</servlet-name>
<url-pattern>*.shtml</url-pattern>
</servlet-mapping>
*第一段中需要加上解析中文编码
<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>
context.xml 为 Context 加上
privileged="true" 属性 例如:
<Context privileged="true">
<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>
不多说直接上代码
SSI用法:
必须为*.shtml页面加载 例如:index.shtml
<!-- header -->
<!--#include virtual="header.html" -->
<!-- news -->
<!--#include virtual="news.html" -->
<!-- guild -->
<!--#include virtual="guild.html" -->
<!-- service -->
<!--#include virtual="service.html" -->
<!-- friendLink -->
<!--#include virtual="friendLink.html" -->
<!-- footer -->
<!--#include virtual="footer.html" -->
转载自:http://www.cnblogs.com/qzsonline/archive/2012/01/06/2314035.html更多推荐
已为社区贡献2条内容
所有评论(0)