SpringBoot: 8.整合freemarker(转)】的更多相关文章

前后端分离现在越来越多,如何有效的使用springboot来整合我们的页面是一个很重要的问题. springboot整合freemarker有以下几个步骤,也总结下我所犯的错误: 1.加依赖: 2.配置文件修改: 3.在templates下面编写后缀为ftl的页面: 4.错误出现:404问题: (1)检查是@RestController还是@Controller,如果要返回页面必须用@Controller (2)这次问题出现的很粗心:(漏掉一个小点)…
springboot 整合 freemarker 依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.6.RELEASE</version> </parent> <dependencies> <depend…
原 ElasticSearch学习笔记Ⅲ - SpringBoot整合ES 新建一个SpringBoot项目.添加es的maven坐标如下: <dependency> <groupId>org.elasticsearch.client</groupId&... 原 SpringBoot+ActiveMQ启动报错:'JmsAutoConfiguration did not match'问题分析 SpringBoot整合ActiveMQ,一切准备工作就绪之后,启动报错如下…
2.4.4 SpringBoot静态资源访问(9) Springboot默认提供静态资源目录位置需放在classpath下,目录名需要符合如下规则 /static  /public  /resources  /META-INF/resources 可以在src/main/resources目录下创建static,在该位置放置一个图片文件. 启动程序后,尝试访问http://localhost:8080/D.JPG,如能显示图片,配置成功. 2.5 SpringBoot整合freemarker视图…
SpringBoot整合Freemarker 1.修改pom文件,添加坐标freemarker启动器坐标 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.ap…
FreeMarker 介绍 Apache FreeMarker™是一个模板引擎:一个Java库,用于根据模板和更改数据生成文本输出(HTML网页,电子邮件,配置文件,源代码等).模板是用FreeMarker模板语言(FTL)编写的,这是一种简单的专用语言(不像PHP这样的完整编程语言).通常,使用通用编程语言(如Java)来准备数据(发布数据库查询,进行业务计算).然后,Apache FreeMarker使用模板显示准备好的数据.在模板中,您将专注于如何呈现数据,而在模板之外,您将关注于要呈现的…
springboot整合freemarker 1.pom依赖 <!-- 引入freeMarker的依赖包. --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-freemarker</artifactId> </dependency> 2.配置application.properties s…
案例springboot_freemarker application.properties配置文件 ###FreeMarker配置 spring.freemarker.template-loader-path=classpath:/templates/ spring.freemarker.cache=false spring.freemarker.charset=UTF- spring.freemarker.check-template-location=true spring.freemar…
SpringBoot静态资源访问 1.静态资源:访问 js / css /图片,传统web工程,webapps springboot 要求:静态资源存放在resource目录下(可以自定义文件存放) 2.整合Freemarker视图层 使用Freemarker模板引擎渲染web视图 pom文件引入 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-…
需求产生原因 要求在同一个接口中,根据不同的参数,返回不同的视图结果 所有的视图中的数据基本一致 要求页面能静态化,优化SEO 例如:A接口返回客户的信息 客户A在调用接口时,返回其个性化定制的页面A 客户B在调用这个接口时,返回其个性化主页B 实现方式 freemaker 的 TemplateLoader freemaker的配置类freemarker.template.Configuration中提供了一个配置模版加载器的方法setTemplateLoader,需求是要求同时能加载本地和远程…