「Java」カスタムタグ(taglib)を作成するサンプル

1.demo.tld

<?xml version="1.0″ encoding="UTF-8″ standalone="no"?>

<!DOCTYPE taglib PUBLIC “-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" “http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">

<taglib>

<tlib-version>xxx</tlib-version>

<jsp-version>xxx</jsp-version>

<short-name>s</short-name> <tag>

<name>fielderror</name>

<tag-class>xxxx</tag-class>

<body-content>empty</body-content>

<description>one column fielderror</description>

<attribute>

<name>key</name>

<required>true</required>

<rtexprvalue>true</rtexprvalue>

<description>addFieldError operate keyname</description>    </attribute>

</tag></taglib>
2.使い方

<%@taglib prefix="k" uri="/jsp/demo.tld" %>

//some code

<k:fielderror key="xxxx"/>

Java

Posted by arkgame