在EAR的多次战争中共享共同的jsp [英] sharing common jsp's in multiple wars in an EAR
问题描述
我们有一个有13个模块的大型应用程序。根据客户要求,我们应该能够部署核心模块+客户特定模块。我们计划将应用程序分成多个战争。现在问题是我们有一些常见的jsp,比如header.jsp,error.jsp等。有没有什么方法可以让我们在核心战争中保持常见的jsp,其余的战争将能够使用它或者我必须复制这些jsp在构建过程中的原始战争中。我知道CSS和Javascript文件可以在耳塞包装的多个战争中共享但不确定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.
推荐答案
好问题。您会很高兴听到答案是是,尽管它高度依赖于您的servlet容器的配置方式。
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.
使用JSTL <$ c完成$ c>< c:import> 标记,其中包含可选的 context
属性,定义为:
It's done using the JSTL <c:import>
tag, which has an optional context
attribute which is defined as:
上下文的名称
(以/开头)的某个
其他本地Web应用程序到
从中导入资源。
Name of the context (beginning with a /) of some other local web application to import the resource from.
所以说你在上下文根 / A
和webapp B下部署了webapp A.部署在 / B
下,然后A中的JSP可以包含来自B的 x.jsp
:
So say you have webapp A deployed under context root /A
, and webapp B deployed under /B
, then a JSP in A can include x.jsp
from B using:
<c:import context="/B" url="x.jsp"/>
这一切都非常好用,但这必须通过servlet容器的安全机制,它可能不允许操作。例如,在Tomcat中 crossContext
属性必须设置为 true
。
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 to true
.
这篇关于在EAR的多次战争中共享共同的jsp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!