Taglib inside Maven dependency banks. How to configure this taglib inside web.xml?

So, I used to configure my taglib as follows:

<jsp-config> <taglib> <taglib-uri>myTags</taglib-uri> <taglib-location>/WEB-INF/lib/mylib-2.0.1.jar</taglib-location> </taglib> </jsp-config> 

But now mylib-2.0.1.jar is a maven dependency, so of course this is NOT included / WEB -INF / lib.

How can I do to configure my taglib so that I can do this in my JSP:

 <%@ taglib uri="myTags" prefix="mt" %> 

EDIT1: To clafiry, taglib.tld is inside META-INF inside the jar, so you can access tld by specifying the jar itself. This is a convenient way to distribute your taglib with the web application framework.

EDIT2: When we deploy webapp, the jar will be in WEB / INF / lib. But during development, inside the eclipse, using m2eclipse, the bank is NOT. Therefore, eclipse complains that it cannot find taglib no where, because there is no jar, and I cannot link to my jar in web.xml.

+2
source share
2 answers

You do not need to configure anything in web.xml , if taglib is located in \META-INF\taglib.tld inside your bank, it will automatically be recognized by Tomcat.

You can use jsp:

 <% @ Taglib prefix = "my" uri = "http://www.mytags.com/"%> 
+3
source

If you add a taglig dependency to your POM, it will be added to the WEB-INF / lib directory of your web application.

  <dependency> <groupId>yourTageLib</groupId> <artifactId>mylib</artifactId> <version>2.0.1</version> <scope>compile</scope> </dependency> 
+2
source

Source: https://habr.com/ru/post/958492/


All Articles