I get this exception when I try to import JspTaglibs in a spring boot application.
freemarker.template.TemplateModelException: No mapping defined for http://www.springframework.org/tags/form
Hear is part of my ftl file, when I try to import it.
<#import "/spring.ftl" as spring/>
<#assign form=JspTaglibs["http://www.springframework.org/tags/form"] />
Get this problem only when starting the application as a spring boot app, works if deployed on standalone tomcat with a war file.
Any ideas ?
You need to add the code below to give templates path.
@Configuration
public class EmailConfiguration {
@Bean(name ="freemarkerConfig")
public FreeMarkerConfigurer getFreemarkerConfig() {
FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
configurer.setTemplateLoaderPath("**classpath:mail**/");
Map<String, Object> map = new HashMap<>();
map.put("xml_escape", new XmlEscape());
configurer.setFreemarkerVariables(map);
return configurer;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.