Java:jsp: A simple custom label TLD
Please note that the URI is: Http://www.tag.com/mytag, keep unified, otherwise error, cannot access
TLD file
1<?xml version="1.0"encoding="UTF-8"?>2<taglib xmlns="HTTP://JAVA.SUN.COM/XML/NS/J2EE"3Xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"4xsi:schemalocation="HTTP://JAVA.SUN.COM/XML/NS/J2EE5http//java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd "6version="2.0">7<description>mytag1.1Print library</description>8<display-name>mytag Tag Library </display-name>9<tlib-version>1.0</tlib-version>Ten< Short-name>mytag</ Short-name> One<uri>http://www.tag.com/mytag</uri> A<tag> -<description> Print hello</description> -<name>print</name> the<tag-class>cn.tag.mytagprint</tag-class> -<body-content>empty</body-content> -</tag> -</taglib>
Add the Jsp-config configuration to the Web. xml file, and if you make an error, put the Web. XML Header "<! DOCTYPE Web-app Public "-//sun Microsystems, INC.//DTD Web application 2.3//en" "http://java.sun.com/dtd/web-app_2_ 3.dtd ">" removed:
1<web-app>2<display-name>archetype Created Web application</display-name>3 4<resource-ref>5<description>db connection</description>6<res-ref-name>jdbc/test</res-ref-name>7<res-type>javax.sql.DataSource</res-type>8<res-auth>Container</res-auth>9</resource-ref>Ten One A<jsp-config> -<taglib> -<taglib-uri>http://www.tag.com/mytag</taglib-uri> the<taglib-location>/WEB-INF/mytlds/mytag.tld</taglib-location> -</taglib> -</jsp-config> - + -</web-app>
tag.jsp
1<%@ page language="Java"Contenttype="text/html; Charset=utf-8"%>2<%@ taglib prefix="MyTag"Uri="Http://www.tag.com/mytag"%>345<body>6 78Result of calling the print label: <mytag:print/>9 Ten</body> OneJava:jsp: A simple custom label TLD