基于Struts2的自定义标签编辑1,建立Tag文件,该文件继承于struts2的基本标签组件,如果查看struts2源码,可以
基于Struts2的自定义标签编辑
1,建立Tag文件,该文件继承于struts2的基本标签组件,如果查看struts2源码,可以看到该类继承了BodyTagSupport,即是一个标准的JSP标签
<taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd">
<description><![CDATA["To make it easier to access dynamic data;
the Apache Struts framework includes a library of custom tags.
The tags interact with the framework's validation and internationalization features;
to ensure that input is correct and output is localized.
The Struts Tags can be used with JSP FreeMarker or Velocity."]]></description>
<display-name>"Melon Tags"</display-name>
<tlib-version>2.0</tlib-version>
<short-name>m</short-name>
<uri>/melon-tags</uri>
<!--自定义测试 -->
<tag>
<description><![CDATA[Execute an action from within a view]]></description>
<name>textwrap</name>
<tag-class>net.esj.struts.views.jsp.TextWrapTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<description><![CDATA[Value to be displayed]]></description>
<name>value</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<dynamic-attributes>false</dynamic-attributes>
</tag>
</taglib>
在使用struts的框架中这样添加自定义标签就几乎不用去了解jsp的标签定义了,什么pagecontext多麻烦