How to add TLD and Tag Lib files into a Maven's jar project

前端 未结 2 775
说谎
说谎 2021-02-05 17:54

I have a Maven project that is packaged as jar.

And I also have a Maven project that is packaged as war. This war project has a tld file and so

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-05 18:40

    @duffymo - Your solution totally works. Adding graphic to your description.

    Create a maven project that generates JAR. keep the structure like this below

     src -- main
                |-- java
                |      `-- net
                |            `-- madhur
                |                 `-- helloTag.java
                `-- resources
                      `-- META-INF
                            `-- tags
                                 `-- customTags.tld
    

    To your customTags.tld file add uri something like this

    http://www.xyzabc.com/taglibs/customTags
    

    Accessing tags in you WAR file

    War should have following structure

      META-INF/
      META-INF/MANIFEST.MF
      WEB-INF/
      WEB-INF/classes/
      WEB-INF/lib/
      WEB-INF/lib/{tagLibrary}.jar
      WEB-INF/web.xml
      WEB-INF/customTags.tld
    

    web.xml

        
            
                www.xyzabc.com/taglibs/customTags
                /WEB-INF/customTags.tld
            
        
    

    Using tag in FTL or JSP file

    Ftl:

    <#assign ct = JspTaglibs["www.xyzabc.com/taglibs/customTags"]>
    

提交回复
热议问题