欢迎来到代码驿站!

JAVA代码

当前位置:首页 > 软件编程 > JAVA代码

springboot整合freemarker详解

时间:2021-04-05 10:11:38|栏目:JAVA代码|点击:

前提:

开发工具:idea

框架:spring boot、maven

1、pom文件添加依赖

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-freemarker</artifactId>
      <version>1.4.1.RELEASE</version>
    </dependency>

2、新建spring web项目,会自动生成application.properties.

使用application.properties配置文件之后,spring boot启动时,会自动把配置信息读取到spring容器中,并覆盖spring boot的默认配置。

3、在配置文件中,设置以下两个参数

#设定ftl文件路径
spring.freemarker.template-loader-path=classpath:/templates
#设定静态文件路径,js,css等
spring.mvc.static-path-pattern=/static/**

controller跳转页面如下:

templates/action/list.ftl页面

 

上一篇:Spring Boot/Angular整合Keycloak实现单点登录功能

栏    目:JAVA代码

下一篇:基于Java ORM框架的使用详解

本文标题:springboot整合freemarker详解

本文地址:http://www.codeinn.net/misctech/95135.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有