Java:jsp: A simple custom label TLD

Source: Internet
Author: User
Tags tld

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> One

Java:jsp: A simple custom label TLD

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.