问题
I need to define a jsp tag which named "include". It should be used as:
<cms:include page="/aaa.jsp" />
It has an attribute page
which points to another jsp, and it will include the content of that jsp and render it.
Is there any existing tag lib can do this? Or please give me some advises of implementing it, thanks!
UPDATE
From Ramesh PVK's answer, I know there is a standard <jsp:include>
fit my need.
But per my project's requirements, I can use the name jsp:include
, but cms:include
. I've already defined some other tags which have prefix cms
, and the include
one should have the same prefix.
Is it possible to find the tld
file for jsp:include
? That I can copy the declarations to my tld file to reuse the tag with new prefix.
回答1:
Already there is a standard jsp tag for this.
This is to include page at runtime.
<jsp:include page="includedPage" />
and
This is to include page at compile time.
<%@ include file="banner.jsp" %>
Links:
- See this tutorial
- Reference
- Different between jsp:include and @include
回答2:
There is already an include tag in JSP that include other static or dynamic JSP or other resource in current JSP. Your requirement is exact same and can be done by jsp include tag. You can learn more on JSP Include tag and other JSP related things on apekshit.com
来源:https://stackoverflow.com/questions/9188478/how-to-implement-a-include-jsp-tag