在web-inf目录中新建一个tld文件,在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>JSTL 1.1 core library</description>
<display-name>JSTL core</display-name>
<tlib-version>1.1</tlib-version>
<short-name>c</short-name>
<uri>http://java.sun.com/jsp/jstl/core</uri><!--此行填写你自己标签库的uri-->
<tag>
<name>viewIP</name>
<tag-class>cn.guo.web.tag.ViewIPTag</tag-class>
<body-content>empty</body-content>
</tag>
</taglib>
注意:其中的<body-content>empty</body-content>中,共有四个值可以填写。包括:
EMPTY :无标签体
JSP:jsp页面,可以含java代码的
scriptless:无脚本的,也就是说,不能内嵌java代码的
tagdepentend:表示,该标签体是给标签用的。不是个整个页面用的
例如:
<c:conn>
select * from user;
</c:conn>
这个标签体就是只给数据库标签用的。
<?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>JSTL 1.1 core library</description>
<display-name>JSTL core</display-name>
<tlib-version>1.1</tlib-version>
<short-name>c</short-name>
<uri>http://java.sun.com/jsp/jstl/core</uri><!--此行填写你自己标签库的uri-->
<tag>
<name>viewIP</name>
<tag-class>cn.guo.web.tag.ViewIPTag</tag-class>
<body-content>empty</body-content>
</tag>
</taglib>
注意:其中的<body-content>empty</body-content>中,共有四个值可以填写。包括:
EMPTY :无标签体
JSP:jsp页面,可以含java代码的
scriptless:无脚本的,也就是说,不能内嵌java代码的
tagdepentend:表示,该标签体是给标签用的。不是个整个页面用的
例如:
<c:conn>
select * from user;
</c:conn>
这个标签体就是只给数据库标签用的。