且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

几个罐子中的freemarker模板

更新时间:2023-11-19 20:28:46

我找到了解决方案!关闭 preferFileSystemAccess 以始终通过SpringTemplateLoader加载.

I found solution! Turn off preferFileSystemAccess to always load via SpringTemplateLoader.

    <!-- freemarker config -->
<bean id="freemarkerConfig"
    class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
    <property name="templateLoaderPaths" value="classpath:/freemarker/" />
    <property name="preferFileSystemAccess" value="false" />
</bean>

public void setPreferFileSystemAccess (布尔PreferredFileSystemAccess)

public void setPreferFileSystemAccess(boolean preferFileSystemAccess)

设置是否更喜欢文件系统访问来进行模板加载.通过文件系统访问,可以热检测模板更改.

Set whether to prefer file system access for template loading. File system access enables hot detection of template changes.

如果启用了此选项,则FreeMarkerConfigurationFactory将尝试将指定的"templateLoaderPath"解析为文件系统资源(也适用于扩展的类路径资源和ServletContext资源).

If this is enabled, FreeMarkerConfigurationFactory will try to resolve the specified "templateLoaderPath" as file system resource (which will work for expanded class path resources and ServletContext resources too).

默认为"true".关闭此选项可始终通过SpringTemplateLoader加载(即作为流,而不会热检测模板更改),如果您的某些模板位于扩展的类目录中,而另一些模板位于jar文件中,则可能有必要.

Default is "true". Turn this off to always load via SpringTemplateLoader (i.e. as stream, without hot detection of template changes), which might be necessary if some of your templates reside in an expanded classes directory while others reside in jar files.