您的位置:首页 > 编程语言 > Java开发

Spring Boot整合Freemarker

2018-02-23 14:50 676 查看
整合Freemarker:
第一步:在pom文件中加入依赖: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-freemarker</artifactId> </dependency>第二步:配置配置文件:在application.properties中配置freemarker:spring.freemarker.charset=UTF-8spring.freemarker.cache=falsespring.freemarker.allow-request-override=falsespring.freemarker.check-template-location=truespring.freemarker.content-type=text/htmlspring.freemarker.expose-request-attributes=falsespring.freemarker.expose-session-attributes=falsespring.freemarker.expose-spring-macro-helpers=false#spring.freemarker.prefix=#spring.freemarker.request-context-attribute=#spring.freemarker.settings.*=#spring.freemarker.suffix=.ftl#spring.freemarker.template-loader-path=classpath:/templates/#spring.freemarker.view-names=在application.yml中配置freemarker:spring: application: name: finance-test freemarker: template-loader-path:classpath:/templates (资源路径) suffix:.ftl (文件后缀) expose-request-attributes:true request-context-attribute:request classic_compatible:true
freemarker配置详情:spring.freemarker.template-loader-path=classpath:/web/spring.freemarker.cache=falsespring.freemarker.charset=UTF-8spring.freemarker.check-template-location=truespring.freemarker.content-type=text/htmlspring.freemarker.expose-request-attributes=truespring.freemarker.expose-session-attributes=truespring.freemarker.request-context-attribute=requestspring.freemarker.suffix=.ftl
更多的 FreeMarker 配置详解:spring.freemarker.allow-request-override=false英语: Set whether HttpServletRequest attributes are allowed to override (hide) controller generated model attributes of the same name.翻译:设置是否允许HttpServletRequest属性覆盖(隐藏)控制器生成的具有相同名称的模型属性。spring.freemarker.allow-session-override=false#英语: Set whether Htt
a674
pSession attributes are allowed to override (hide) controller generated model attributes of the same name.翻译:设置是否允许HttpSession属性覆盖(隐藏)同名控制器生成的模型属性。spring.freemarker.cache=false英语: Enable template caching.翻译:启用模板缓存。spring.freemarker.charset=UTF-8英语: Template encoding.翻译:模板编码。spring.freemarker.check-template-location=true英语: Check that the templates location exists.翻译:检查模板位置是否存在。spring.freemarker.content-type=text/html英语: Content-Type value.翻译:内容类型值。spring.freemarker.enabled=true英语: Enable MVC view resolution for this technology.翻译:为此技术启用MVC视图分辨率。spring.freemarker.expose-request-attributes=false英语: Set whether all request attributes should be added to the model prior to merging with the template.翻译:设置在与模板合并之前是否应将所有请求属性添加到模型中。spring.freemarker.expose-session-attributes=false英语: Set whether all HttpSession attributes should be added to the model prior to merging with the template.翻译:设置是否应该在与模板合并之前将所有HttpSession属性添加到模型中。spring.freemarker.expose-spring-macro-helpers=true英语: Set whether to expose a RequestContext for use by Spring's macro library, under the name "springMacroRequestContext".翻译:设置是否公开一个由Spring的宏库使用的名为“springMacroRequestContext”的RequestContext。spring.freemarker.prefer-file-system-access=true英语: Prefer file system access for template loading. File system access enables hot detection of template changes.翻译:首选文件系统访问模板加载。 文件系统访问启用模板更改的热检测。spring.freemarker.prefix=英语: Prefix that gets prepended to view names when building a URL.翻译:在构建URL时,前缀会被视为查看名称。spring.freemarker.request-context-attribute=英语: Name of the RequestContext attribute for all views.翻译:所有视图的RequestContext属性的名称。spring.freemarker.settings.*=英语: Well-known FreeMarker keys which will be passed to FreeMarker's Configuration.翻译:将已知的FreeMarker键将被传递给FreeMarker的配置。spring.freemarker.suffix=英语: Suffix that gets appended to view names when building a URL.翻译:在构建URL时被附加到查看名称的后缀。spring.freemarker.template-loader-path=classpath:/templates/英语: Comma-separated list of template paths.翻译:模板路径列表。spring.freemarker.view-names=英语: White list of view names that can be resolved.翻译:可以解决的视图名称的白名单。
有兴趣的小伙伴可以加群一起交流:606278528
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息