在 EAR 中的多个战争中共享公共 jsp
我们有一个包含 13 个模块的大型应用程序。根据客户需求,我们应该能够部署核心模块+客户特定模块。我们计划将应用程序分成多场战争。现在的问题是我们有一些常见的jsp,如header.jsp、error.jsp等。有什么方法可以让我们将常见的jsp保留在核心战争中,并且其余的战争将能够使用它,否则我必须复制这些jsp 在构建过程中处于个体战争中。我知道CSS和Javascript文件可以在ear包装中的多个wars之间共享,但不确定jsp的。
We have a big application having 13 modules. Depending on the customer requirement, we should able to deploy core module+customer specific modules. We are planning to break the app into multiple wars. Now problem is we have some common jsp's like header.jsp, error.jsp etc. Is there any way by which we can keep the common jsp's in core war and rest of the wars will be able to use it or I have to copy these jsp's in the invidiual wars in build process. I know CSS and Javascript files can be shared across multiple wars in ear packaging but not sure about jsp's.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好问题。您会很高兴听到答案是“是”,尽管这很大程度上取决于您的 servlet 容器的配置方式。
这是使用 JSTL
标记完成的,该标记有一个可选的context
属性,定义为:假设您将 webapp A 部署在上下文根
/A
下,并将 webapp B 部署在/B
下,那么 A 中的 JSP 可以包含x.jsp from B using:
这一切都非常美好,但是这必须通过servlet容器的安全机制,并且它可能不允许该操作。例如,Tomcat 中的
crossContext
属性必须设置为true
。Good question. You'll be happy to hear that the answer is "yes", although it's highly dependent on how your servlet container is configured.
It's done using the JSTL
<c:import>
tag, which has an optionalcontext
attribute which is defined as:So say you have webapp A deployed under context root
/A
, and webapp B deployed under/B
, then a JSP in A can includex.jsp
from B using:This is all very nice and rosy, but this has to pass through the servlet container's security mechanism, and it may not permit the operation. For example, in Tomcat the
crossContext
attribute must be set totrue
.