springboot整合freemarker

本文详细介绍如何在SpringBoot项目中集成FreeMarker模板引擎,包括添加依赖、配置属性及使用controller进行页面跳转的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前提:

开发工具: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页面

 

 

 

 

 

转载于:https://www.cnblogs.com/amunamuna/p/6400273.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值