如何实现“包括"功能. jsp标签? [英] How to implement a "include" jsp tag?

查看:98
本文介绍了如何实现“包括"功能. jsp标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要定义一个名为"include"的jsp标记.它应该用作:

I need to define a jsp tag which named "include". It should be used as:

<cms:include page="/aaa.jsp" />

它具有一个属性page,该属性指向另一个jsp,它将包含该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!

更新

Ramesh PVK的答案,我知道有一个符合我需要的标准<jsp:include>.

From Ramesh PVK's answer, I know there is a standard <jsp:include> fit my need.

但是根据项目的要求,我可以使用名称jsp:include,但可以使用cms:include.我已经定义了其他一些带有前缀cms的标签,而include一个标签应该具有相同的前缀.

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.

是否可以找到jsp:includetld文件?我可以将声明复制到我的tld文件中,以重新使用带有新前缀的标记.

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.

推荐答案

已经有一个标准的jsp标记.

Already there is a standard jsp tag for this.

This is to include page at runtime.
<jsp:include page="includedPage" />

This is to include page at compile time.
<%@ include file="banner.jsp" %>

链接:

  • See this tutorial
  • Reference
  • Different between jsp:include and @include

这篇关于如何实现“包括"功能. jsp标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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