Richard G
Richard G

Reputation: 5683

How to configure taglib with java configuration

I got rid of web.xml and replaced it with 2 classes to configure the servlet environment.

public class UsersWebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer

and

public class WebConfig extends WebMvcConfigurerAdapter

My question is, how can I use one of these classes to configure the equivalent of a taglib declaration in the Web.xml?

e.g - how would I write this in java configuration?

<taglib>
  <taglib-uri>
    http://www.example.com/taglib
  </taglib-uri>
  <taglib-location>
    /taglib.tld
  </taglib-location>
</taglib>

Upvotes: 0

Views: 2092

Answers (1)

endriu_l
endriu_l

Reputation: 1659

You don't have to configure anything. Since JSP 2.0 taglibs can be discovered automatically.

All You need to do is place them in WEB-INF or it's subfolders. If you are packaging Your TLDs as JAR files, place them in WEB-INF/lib or META-INF of the JAR

Upvotes: 2

Related Questions