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

前端 未结 1 1059
情书的邮戳
情书的邮戳 2020-11-29 11:28

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

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

The above code

相关标签:
1条回答
  • 2020-11-29 12:15

    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.

    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" />
    

    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.

    alt text

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

    0 讨论(0)
提交回复
热议问题