Spring-Boot with JSP Tag Libs in embedded Tomcat

后端 未结 5 1612
离开以前
离开以前 2021-01-19 00:52

I am currently migrating a Spring MVC Webapp (xml-config to java-config, tomcat to embedded tomcat via spring-boot).

The webapp uses freemarker as templating engine

5条回答
  •  我在风中等你
    2021-01-19 01:34

    While rendering template, freemarker call TaglibFactory, which search for TLD in fours ways:

    1. addTldLocationsFromClasspathTlds
    2. addTldLocationsFromWebXml
    3. addTldLocationsFromWebInfTlds
    4. addTldLocationsFromMetaInfTlds

    All of these methods are in TablibFactory class at freemarker jar. That last one, scan every jar in WEB-INF/lib searching for /META-INF/**/*.tld. You can see this logging if debug mode for freemarker is enabled.

    Take a look how your project is deployed. In my case, using eclipse, wtp, tomcat and maven, the maven dependencies was configured in Eclipse/Deployment assembly as maven dependencies, of course :), hence these libs are not in WEB-INF/lib and so, was not found by addTldLocationsFromMetaInfTlds.

    A way to solve is forcing deployment to copy all maven dependencies to WEB-INF/lib. I did it opening server configuration, at eclipse view 'servers', under server options uncheck all checkboxes but 'Module auto reload by default'.

提交回复
热议问题