将magnoliaPublic上下文内容嵌入到其他Web应用程序上下文中 [英] Embed magnoliaPublic context content into a different web app context

查看:103
本文介绍了将magnoliaPublic上下文内容嵌入到其他Web应用程序上下文中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试将Magnolia管理的内容嵌入到现有Web应用程序的某些JSP中.在Tomcat中,我们部署并设置了一个 magnoliaPublic 上下文,该上下文沿着我们现有的 app 上下文(即两个不同的WAR文件)运行.在浏览器中,您可以同时访问:

We're trying to embed Magnolia-managed content into some of the JSPs of an existing web app. In Tomcat we deployed and set up a magnoliaPublic context that runs along our existing app context (i.e. two different WAR files). In the browser you can access both:

  • http://localhost:8080/app/test.jsp
  • http://localhost:8080/magnoliaPublic/footer
  • http://localhost:8080/app/test.jsp and
  • http://localhost:8080/magnoliaPublic/footer

因此,例如,我们希望/app/test.jsp包含一个像/magnoliaPublic/footer这样的木兰页面(只是一个div).我们通过添加以下内容来做到这一点:

So, for example, we'd like /app/test.jsp to include a Magnolia page like /magnoliaPublic/footer (just a div). We managed to do it by adding:

<c:import url="http://localhost:8080/magnoliaPublic/footer" />

/app/test.jsp.几乎可以,但是最好使用相对包含:

to /app/test.jsp. This is almost fine, but a relative include would be best:

<c:import context="/magnoliaPublic" url="/footer" />

后一行抛出

The requested resource (/magnoliaPublic/footer) is not available

我怀疑这是由于Magnolia的过滤器链的工作方式造成的,尽管它已设置为分派INCLUDE,并且所有服务器/过滤器/调度/*条目的toMagnoliaResources都设置为true.

I suspect this is due to the way Magnolia's filter chain works, though it's set to dispatch INCLUDE and all server/filters/dispatching/* entries have toMagnoliaResources set to true.

任何提示将不胜感激.

谢谢.

推荐答案

Tomcat默认情况下不允许您访问其他Servlet上下文.我想这就是您使用context属性的c:import失败的原因.

Tomcat does not allow you to access another Servlet Context by default. I guess that is the reason why your c:import using the context attribute fails.

Tomcat具有crossContext属性,该属性对此进行配置:

Tomcat has the crossContext attribute which configures this:

如果要在此应用程序内调用ServletContext.getContext()以成功返回在此虚拟主机上运行的其他Web应用程序的请求分派器,请设置为true.在注重安全的环境中设置为false(默认值),以使getContext()始终返回null.

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.

来源: http://tomcat.apache.org/tomcat- 7.0-doc/config/context.html

启用crossContext可能会解决您的问题.

Enabling crossContext might solves your problem.

这篇关于将magnoliaPublic上下文内容嵌入到其他Web应用程序上下文中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆