一般我们开发使用的是jstl也就是C标签,或者是Struts2提供的标签。但是对于有些业务需要自己定义标签。比方说在多个页面都需要使用社区名称。虽然知道社区ID,但还要通过ID进行查找一番,很是麻烦。所以通过自定义标签可以很好的解决,减少了代码的重复率,便于维护。
<!--[if !supportLists]-->1.1 <!--[endif]-->简单输出,没有属性

编写标签java
编写标签描述文件xml
Xml字段的含义
Jsp页面的访问
标签访问的过程:
<!--[if !supportLists]-->1.2 <!--[endif]-->带属性的输出
带有属性format。Java文件
Tld文件
<!--[if !supportLists]-->1.3 Tagspport核心类
该类是自定义标签的核心,主要实现了两个接口:Tag接口、iterationTag接口


1.4 dostartTag方法
<!--[if !supportLists]-->1.5 <!--[endif]-->doAafterTag标签
<!--[if !supportLists]-->1.6 doEndTag标签
<!--[if !supportLists]-->1.7 <!--[endif]-->Release资源释放操作
<!--[if !supportLists]-->1.8Tag接口程序执行流程
<!--[if !supportLists]-->1.9 <!--[endif]-->IterationTag接口的执行流程
如果向页面简单的输出可以使用:
pageContext.getOut().print("<h1>helloworld!"+info+"</h1>");
直接在页面可以进行打印。
也可以像页面设置属性值:
pageContext.setAttribute("list", list);
在页面上用EL表达式取值。
<!--[if !supportLists]-->1.10 <!--[endif]-->自定义标签实例:迭代标签
切记:标签编写只在dostartTag()和daAfterTag()用的比较多,doEndTag()用的很少。