[標(biāo)題]:Tomcat crossContext
[時間]:2009-6-1
[摘要]:當(dāng)<c:import >指定了context屬性時,應(yīng)該設(shè)置%TOMCAT_HOME%/conf/context.xml的Context中的屬性crossContext="true"。
[關(guān)鍵字]:context、tag、crossContext、JSP、Servlet
[環(huán)境]:Tomcat 6、Window XP SP3
[作者]:Winty (wintys@gmail.com) http://m.tkk7.com/wintys
[錯誤]:
在使用<c:import url="/MyHtml.html" context=”/sample2” var="thisPage"/>時,使用context指定了同一服務(wù)器下的另一個WebApp的資源時(即訪問WEB_ROOT/sample2/MyHtml.html),出現(xiàn)如下錯誤提示:
javax.servlet.ServletException: javax.servlet.jsp.JspTagException: In URL tags, when the "context" attribute is specified, values of both "context" and "url" must start with "/".
[原因]:
Tomcat默認(rèn)不能跨WebApp進(jìn)行訪問。
[解決]:
%TOMCAT_HOME%/conf/context.xml的Context中的屬性crossContext="true"。
完整的context.xml內(nèi)容如下:
<!-- The contents of this file will be loaded for each web application -->
<Context crossContext="true">
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
</Context>
Tomcat文檔中對crossContext的說明:Set to true if you want calls within this application to ServletContext.getContext() to successfully return a request dispatcher for other web applications running on this virtual host. Set to false (the default) in security conscious environments, to make getContext() always return null.
[參考資料]:
%TOMCAT_HOME%/webapps/docs/config/context.html
posted on 2009-06-01 12:27
天堂露珠 閱讀(3632)
評論(1) 編輯 收藏 所屬分類:
JSP