jsp自定义标签_JSP自定义标签

jsp自定义标签

When EL and Standard Action elements aren't enough to remove scriptlet code from your JSP Page, you can use Custom Tags. Custom tags are nothing but user-defined tags.

当EL和标准动作元素不足以从JSP页面删除scriptlet代码时,可以使用“定制标记”。 自定义标签不过是用户定义的标签。

Custom tags are an excellent way to abstract the complexity of business logic from the presentation of Web pages in a way that is easy for the Web author to use and control. It also allows for reusability as custom tags can be used again and again.

自定义标记是一种以Web作者易于使用和控制的方式从网页的呈现中抽象出业务逻辑复杂性的极好方法。 由于自定义标签可以一次又一次地使用,因此它也允许重用。

JSP自定义标签的格式 (Format of JSP Custom tag)

The format of a custom tag can either be empty, called an Empty tag, or can contain a body, called a Body tag. The number of attributes that a tag will accept depends on the implementation of the Tag Handler class.

自定义标签的格式可以为空(称为Empty标签),也可以包含正文(称为Body标签)。 标签将接受的属性数量取决于Tag Handler类的实现。

Syntax for an Empty Tag is:

空标签的语法是:

<tagLibraryPrefix:customTagName attribute1="attributeName" 
    attribute2="attributeName" ... />

The Syntax for a Custom Body Tag is :

自定义正文标签的语法为:

<tagLibraryPrefix:customTagName attribute1="attributeName" 
    attribute2="attributeName" ... />
  < --Body of custom tag-- >
</tagLibraryPrefix:customTagName>

Creating custom tags is considered as a very good practice in JSP world. Always try to create and use your own custom tags from frequently used operations in your JSP application. Let's move to the next lesson and study how to create a Custom tag.

在JSP世界中,创建定制标记被认为是一种很好的做法。 始终尝试通过JSP应用程序中经常使用的操作来创建和使用自己的定制标记。 让我们进入下一课,学习如何创建自定义标签。

翻译自: https://www.studytonight.com/jsp/custom-tag.php

jsp自定义标签

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值