Spring Freemarker Configuration, Template Not Found

回眸只為那壹抹淺笑 提交于 2019-12-05 11:27:29

Make sure you have the following

  1. In your *-action servlet xml FreeMarkerConfigurationFactoryBean configuration has the "preferFileSystemAccess" property set to "false"

  2. <property name="templateLoaderPath" value="classpath*:/"/> should be <property name="templateLoaderPath" value="classpath:/"/>

    In freemarker the template loader tries to match a string "classpath:" , not "classpath*:"

  3. you have the JAR file under WEB-INF/lib folder.

  4. Finally, your template file under root of the jar file.

Use some bean like this:

<bean
    class="org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean">
    <property name="templateLoaderPath" value="classpath:META-INF/freemarker/" />
    <property name="preferFileSystemAccess" value="false" />
</bean>

Hope this help you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!