[原]Tomcat crossContext

xiaoxiao2026-08-26  3

[标题]:Tomcat crossContext [时间]:2009-6-1 [摘要]:当<c:import >指定了context属性时,应该设置%TOMCAT_HOME%/conf/context.xml的Context中的属性crossContext="true"。 [关键字]:context、tag、crossContext、JSP、Servlet [环境]:Tomcat 6、Window XP SP3 [作者]:Winty (wintys@gmail.com) http://www.blogjava.net/wintys [错误]:     在使用<c:import url="/MyHtml.html" context=”/sample2” var="thisPage"/>时,使用context指定了同一服务器下的另一个WebApp的资源时(即访问WEB_ROOT/sample2/MyHtml.html),出现如下错误提示: 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默认不能跨WebApp进行访问。 [解决]:     %TOMCAT_HOME%/conf/context.xml的Context中的属性crossContext="true"。     完整的context.xml内容如下: <!-- 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
转载请注明原文地址: https://www.6miu.com/read-5051897.html

最新回复(0)