嵌入式Tomcat中具有JSP标签库的Spring-Boot [英] Spring-Boot with JSP Tag Libs in embedded Tomcat

查看:233
本文介绍了嵌入式Tomcat中具有JSP标签库的Spring-Boot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在迁移Spring MVC Webapp(通过spring-boot将xml-config迁移到java-config,将tomcat迁移到嵌入式tomcat).

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

webapp使用freemarker作为模板引擎和JSP Taglib.现在,当我调用一个freemarker页面时,出现以下错误:

The webapp uses freemarker as templating engine and JSP Taglibs. Now when I call a freemarker page I get the following error:

freemarker.ext.jsp.TaglibFactory$TaglibGettingException: 
No TLD was found for the "http://www.springframework.org/tags/form" JSP taglib URI. (TLD-s are searched according the JSP 2.2 specification. In development- and embedded-servlet-container setups you may also need the "MetaInfTldSources" and "ClasspathTlds" freemarker.ext.servlet.FreemarkerServlet init-params or the similar system properites.)

freemarker-header.ftl以以下代码段开头:

The freemarker-header.ftl begins with following snippet:

<#assign form=JspTaglibs["http://www.springframework.org/tags/form"]>
<#assign core=JspTaglibs["http://java.sun.com/jstl/core"]>
<#assign spring=JspTaglibs["http://www.springframework.org/tags"]>
<#assign osc=JspTaglibs["/WEB-INF/osc.tld"]>

我没有找到任何可用的MetaInfTldSources和ClasspathTlds搜索结果.有人解决过这个问题吗?

I did not find any usable search results for MetaInfTldSources and ClasspathTlds. Any one solved this problem before?

KR 哈比卜

推荐答案

Spring Boot不支持使用带有Freemarker的JSP taglib.您可能会感兴趣的打开增强请求.其中包含一个链接到一个可能的解决方法,在该方法中,您配置FreemarkerConfigurer的标签库工厂以及要从类路径中加载的一些其他TLD:

Spring Boot doesn't support the use of JSP taglibs with Freemarker out of the box. There's an open enhancement request that you might be interested in. It contains a link to a possible workaround where you configure FreemarkerConfigurer's tag lib factory with some additional TLDs to be loaded from the classpath:

freeMarkerConfigurer.getTaglibFactory().setClasspathTlds(…);

这篇关于嵌入式Tomcat中具有JSP标签库的Spring-Boot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆