tag_tld(cusTag).txt
根据提供的文件信息,我们可以分析出该文件主要涉及JavaServer Pages (JSP) 中的自定义标签库(Custom Tag Library)的定义与使用。文件通过XML格式定义了一个名为`JSTLcore`的标签库,其中包含了三个核心元素:一个循环标签`forEach`、一个函数`add`以及一个属性获取标签`getProperty`。下面将详细解析这些知识点。 ### 1. 自定义标签库 (Custom Tag Library) 自定义标签库是JSP中一种非常实用的功能,它允许开发者封装复杂的逻辑到标签中,从而使JSP页面更加简洁和易于维护。在JSP中使用自定义标签可以显著提高开发效率,并使得代码更加模块化和可重用。 #### 1.1 标签库元数据 - **描述**: `<description>Զǩ</description>` 这里表示对标签库的一个简短描述。 - **显示名称**: `<display-name>JSTLcore</display-name>` 定义了标签库的显示名称。 - **版本号**: `<tlib-version>1.1</tlib-version>` 表示当前标签库的版本号。 - **简短名称**: `<short-name>firstLabel</short-name>` 给出一个简短的标识符用于区分不同的标签库。 - **URI**: `<uri>http://java.sun.com/jsp/jstl/core</uri>` 指定了该标签库的唯一资源定位符(URI),这是在JSP页面中引用自定义标签时使用的命名空间。 #### 1.2 循环标签 `forEach` - **名称**: `<name>forEach</name>` 表示标签的名称。 - **类名**: `<tag-class>com.lin.tag.ForEach</tag-class>` 指定了实现该标签功能的Java类。 - **Body Content**: `<body-content>JSP</body-content>` 指定标签体的内容类型,这里为JSP表示允许在标签体内嵌入JSP脚本或表达式。 - **属性**: - `id`: `<name>id</name>` 属性名称。 - `<required>true</required>` 表示该属性是否必须提供值。 - `<rtexprvalue>true</rtexprvalue>` 表示该属性是否支持运行时表达式的值。 - `collection`: `<name>collection</name>` 同上。 #### 1.3 函数 `add` - **名称**: `<name>add</name>` 定义了函数的名称。 - **类名**: `<function-class>com.lin.tag.ELFunction</function-class>` 指定了实现该函数功能的Java类。 - **签名**: `<function-signature>int add(int, int)</function-signature>` 描述了函数的方法签名,包括返回类型和参数列表。 #### 1.4 属性获取标签 `getProperty` - **名称**: `<name>getProperty</name>` 表示标签的名称。 - **类名**: `<tag-class>com.lin.tag.GetProperty</tag-class>` 指定了实现该标签功能的Java类。 - **Body Content**: `<body-content>empty</body-content>` 表示不允许在标签体内放置任何内容。 - **属性**: - `name`: `<name>name</name>` 属性名称。 - `<required>true</required>` 表示该属性是否必须提供值。 - `<rtexprvalue>true</rtexprvalue>` 表示该属性是否支持运行时表达式的值。 - `property`: `<name>property</name>` 同上。 ### 总结 通过以上解析可以看出,该自定义标签库定义了三个核心组件:循环标签`forEach`、函数`add`和属性获取标签`getProperty`。这些组件分别封装了循环处理集合、执行简单的数学运算和获取对象属性的功能。在实际开发中,这样的标签库可以大大提高JSP页面的编写效率,减少冗余代码,提高代码的可读性和可维护性。
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
<taglib version="2.0"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:shcemalocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<description>自定义标签</description>
<display-name>JSTL core</display-name>
<tlib-version>1.1</tlib-version>
<short-name>firstLabel</short-name>
<uri>http://java.sun.com/jsp/jstl/core</uri>
<!-- 创建自定义 迭代标签 -->
<tag>
<name>forEach</name>
<tag-class>com.lin.tag.ForEach</tag-class>
<!-- 如果没有标签体,设置empty , 如果有标签休必须设置JSP-->
<body-content>JSP</body-content>
<attribute>
<name>id</name>
<required>true</required><!-- 标识属性是否是必须的 -->
<rtexprvalue>true</rtexprvalue><!-- 标识属性值是否可以用表达式语言 -->
</attribute>
<attribute>
<name>collection</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
- 粉丝: 4
- 资源: 53
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)