不处理体内容的标签理解一下图片1

处理体内容标签理解提图片2

1:JspWriter out = pageContext.getOut();
2:BodyContent bc = this.getBodyContent();
3:String input = bc.getString();
4:JspWriter out = bc.getEnclosingWriter();
不处理体内容
第一行代码为不处理标签体内容时拿到需要的输出到页面的对象
处理体内容
第二行代码为处理标签提内容时拿到包装了提内容信息的对象
第三行代码为拿出体内容。
第四行为拿到页面输出对象。
拿到对象后用out.print方法输出处理后的效果给页面
编写标记配置tld文件:
<?xml version="1.0" encoding="UTF-8" ?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<description>test tag</description>
<tlib-version>1.0</tlib-version>
<short-name>util</short-name>
<uri>/timeTage</uri>
<tag>
<description>fist tag</description>
<name>Showtime</name>
<tag-class>com.test.tag.TimeTag</tag-class>
<body-content>JSP</body-content>
</tag>
<tag>
<description>dateformat</description>
<name>formatTime</name>
<tag-class>com.test.tag.TimeFormat</tag-class>
<body-content>empty</body-content>
<attribute>
<name>date</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>pattern</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
页面中需要:<%@taglib prefix="time" uri="/timeTage" %> 来引用

被折叠的 条评论
为什么被折叠?



