springboot怎么配置velocity.properties文件

springboot怎么配置velocity.properties文件,第1张

统一在application.properties配置:

# VELOCITY TEMPLATES (VelocityAutoConfiguration)

spring.velocity.allow-request-override=false # Set whether HttpServletRequest attributes are allowed to override (hide) controller generated model attributes of the same name.

spring.velocity.allow-session-override=false # Set whether HttpSession attributes are allowed to override (hide) controller generated model attributes of the same name.

spring.velocity.cache= # Enable template caching.

spring.velocity.charset=UTF-8 # Template encoding.

spring.velocity.check-template-location=true # Check that the templates location exists.

spring.velocity.content-type=text/html # Content-Type value.

spring.velocity.date-tool-attribute= # Name of the DateTool helper object to expose in the Velocity context of the view.

spring.velocity.enabled=true # Enable MVC view resolution for this technology.

spring.velocity.expose-request-attributes=false # Set whether all request attributes should be added to the model prior to merging with the template.

spring.velocity.expose-session-attributes=false # Set whether all HttpSession attributes should be added to the model prior to merging with the template.

spring.velocity.expose-spring-macro-helpers=true # Set whether to expose a RequestContext for use by Spring's macro library, under the name "springMacroRequestContext".

spring.velocity.number-tool-attribute= # Name of the NumberTool helper object to expose in the Velocity context of the view.

spring.velocity.prefer-file-system-access=true # Prefer file system access for template loading. File system access enables hot detection of template changes.

spring.velocity.prefix= # Prefix that gets prepended to view names when building a URL.

spring.velocity.properties.*= # Additional velocity properties.

spring.velocity.request-context-attribute= # Name of the RequestContext attribute for all views.

spring.velocity.resource-loader-path=classpath:/templates/ # Template path.

spring.velocity.suffix=.vm # Suffix that gets appended to view names when building a URL.

spring.velocity.toolbox-config-location= # Velocity Toolbox config location. For instance `/WEB-INF/toolbox.xml`

spring.velocity.view-names= # White list of view names that can be resolved.

在velocity.properties中添加如下配置: resource.loader = file,webapp file.resource.loader.description = Velocity File Resource Loader file.resource.loader.class = org.apache.velocity.runtime.resource.loader.FileResourceLoader file.resource.loader.path = . file.resource.loader.cache = false file.resource.loader.modificationCheckInterval = 2 webapp.resource.loader.class = org.apache.velocity.tools.view.servlet.WebappLoader 上面的配置中誉搜或,webapp是用于读取WEB应用根目录下的文件.其实如果没有别的加庆伍载器的话,配不配置WebappLoader都一漏缓样.但是如果配置了其他的加载器,WebappLoader一定要添加,否则会出现org.apache.velocity.exception.ResourceNotFoundException异常


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/12171058.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-21
下一篇 2023-05-21

发表评论

登录后才能评论

评论列表(0条)

保存