如何将来自不同项目的 JSP 文件包含到我的项目中 [英] How do I include a JSP file from a different project into my project

查看:26
本文介绍了如何将来自不同项目的 JSP 文件包含到我的项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将来自不同项目的 JSP 文件包含到我的项目中?

How do I include a JSP file from a different project into my project?

<%@ include file="./common/webappfooter.jsp"%>

上面的代码不起作用.

推荐答案

仅当另一个项目捆绑在主目录的 /WEB-INF/lib 文件夹中的 JAR 文件中时才有效webapp项目,如果JSP文件依次放置在另一个项目的/META-INF/resources文件夹中.

This works only if the other project is bundled in flavor of a JAR file in /WEB-INF/lib folder of the main webapp project and if the JSP file is in turn placed in /META-INF/resources folder of the other project.

因此,如果您在另一个项目中有一个 /META-INF/resources/common/webappfooter.jsp,则应该执行以下包含:

So, if you have a /META-INF/resources/common/webappfooter.jsp in the other project, then the following include should do:

<jsp:include path="/common/webappfooter.jsp" />

如果您使用的是有点自尊的 IDE,您可以将其配置为自动将其他项目捆绑为 webapp 项目的 /WEB-INF/lib 的 JAR.不清楚您使用的是什么 IDE,但在 Eclipse 中,只需在主 webapp 项目的属性中将另一个项目添加为 Deployment Assembly.

If you're using a bit self-respected IDE, you can configure it to automatically bundle the other project as JAR of webapp project's /WEB-INF/lib. It's unclear what IDE you're using, but in Eclipse it's a matter of adding the other project as Deployment Assembly in the main webapp project's properties.

在 Eclipse 中,要创建这样一个准备好正确文件夹结构的项目,请选择Web Fragment Project"向导.

In Eclipse, to create such a project with the right folder structure prepared, choose the "Web Fragment Project" wizard.

这篇关于如何将来自不同项目的 JSP 文件包含到我的项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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