tomcat 6 SSI 配置問題的解決

你也可能遇到了:java.lang.SecurityException: Filter of class org.apache.catalina.ssi.SSIFilter is privileged and cannot be loaded by this web application


tomcat 6 SSI的配置與5.x版本不同,從網上搜索的結果來看,5.xx中要改一個.jar中的文件,而6.x中,卻沒有這個文件
1.首先想到的還是看官方文檔http://tomcat.apache.org/tomcat-6.0-doc/ssi-howto.html,文檔裏說得很清楚:只需把 $CATALINA_BASE/conf/web.xml文件裏 ssi 相關的 servlet servlet-mapping   filter filter-mapping註釋去掉就行
2 啓動,出錯,報了一個安全方面的異常,
java.lang.SecurityException: Filter of class org.apache.catalina.ssi.SSIFilter is privileged and cannot be loaded by this web application再看文檔還有這樣一句話:Only Contexts which are marked as privileged may use SSI features (see the privileged property of the Context element).
我對privileged property of the Context element的理解有誤,先是把$CATALINA_BASE/conf/servlet.xml下的當前項目的 Context中加入了 privileged="true"的屬性(這不正是Context元素的 privileged 屬性嗎),啓動還是報錯.無奈,崩潰中.......
3.我使用的版本 6.0.13中$CATALINA_BASE/conf/下還有一個context.xml 這裏面也有一個context的元素, 加上 privileged="true" 屬性後,再啓動,這次啓動成功了

補充:以上的配置並沒有解決亂碼問題
亂碼的解決:在
$CATALINA_BASE/conf/web.xml中的ssi servlet配置中添加以下初始配置:
        <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>
其中
utf-8應該與你頁面的編碼方式相同

 

在shtml頁面裏<!--#include file="test.html"-->就可以引用靜態文件了

發佈了33 篇原創文章 · 獲贊 4 · 訪問量 20萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章