how to package and use custom taglib (maven jar project)

i created my own taglib. i put the tld file int src/main/resources/META-IN/InputTagDescriptor.tld (using maven project)

<?xml version="1.0" encoding="UTF-8"?>
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>input</shortname>
<info>provides an input tag with escaped value attribute</info>
<uri>http://blubber.com/</uri>
<tag>
    <name>input</name>
    <tagclass>com.vector.extranet.taglib.InputTagHandler</tagclass>
    <info>Creates normal input tag but value will be escaped.</info>
    <attribute>
        <name>name</name>
        <required>true</required>
    </attribute>
    <attribute>
        <name>id</name>
        <required>true</required>
    </attribute>
    <attribute>
        <name>cssClass</name>
        <required>false</required>
    </attribute>
    <attribute>
        <name>maxlength</name>
        <required>false</required>
    </attribute>
    <attribute>
        <name>type</name>
        <required>true</required>
    </attribute>
    <attribute>
        <name>value</name>
        <required>true</required>
    </attribute>
</tag>
</taglib>

In my webapp (liferay portlet, mavenized) i included the dependency of the taglib an imported the tld in jsp:

<%@ taglib uri="http://blubber.com/InputTagDescriptor.tld" prefix="input" %>

The war is packaged as it should: WEB-INFlibtaglib.jarMETA-INFInputTagDescriptor.tld. But on invoking the portlet i got:

12:56:53,486 ERROR [http-bio-8080-exec-12][render_portlet_jsp:157]     org.apache.jasper.JasperException: The absolute uri:
http://blubber.com/InputTagDescriptor.tld cannot be resolved in either web.xml or the jar files deployed with this application

so how to get it working? (it should work without help of web.xml shouldn't it?)


A bit too late probably but you CAN do this quite nicely. Check out this example: http://www.codeyouneed.com/how-to-create-a-taglib-with-jsps-for-liferay/

Just make sure your taglib jar is the dependency of your portlet project so it's packaged along nicely. Also, try restarting liferay as it my find it a bit difficult to pick it up initially. Additional note that you probably can't access your taglib inside a Liferay Hook project.

链接地址: http://www.djcxy.com/p/12962.html

上一篇: 将WAB(OSGI)中的罐子转换成捆绑包有什么用?

下一篇: 如何打包和使用自定义taglib(maven jar项目)