码迷,mamicode.com
首页 > 编程语言 > 详细

spring-boot集成Freemarker开发

时间:2019-07-28 09:15:47      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:file   ges   tin   run   localhost   tis   host   cal   set   

1.该demo功能
http://localhost/system/login展示后台发布新闻列表
http://localhost/前端Freemark模板展示
中间用到了Mysql, Mybatis, druid;可以参考spring-boot相关的demo

2.Pom依赖

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


3.项目启动

@SpringBootApplication
@MapperScan(basePackages="com.lance.freemaker.mapper")
public class SimpleApplication {

public static void main(String[] args) {
SpringApplication.run(SimpleApplication.class, args);
}
}
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter{

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new AdminInterceptor()).addPathPatterns("/system/admin/**");
}
}


4.配置freemarker

# FREEMARKER (FreeMarkerAutoConfiguration)
spring.freemarker.allow-request-override=false
spring.freemarker.allow-session-override=false
spring.freemarker.cache=true
spring.freemarker.charset=UTF-8
spring.freemarker.check-template-location=true
spring.freemarker.content-type=text/html
spring.freemarker.enabled=true
spring.freemarker.expose-request-attributes=false
spring.freemarker.expose-session-attributes=false
spring.freemarker.expose-spring-macro-helpers=true
spring.freemarker.prefer-file-system-access=true
spring.freemarker.suffix=.ftl
spring.freemarker.template-loader-path=classpath:/templates/
spring.freemarker.settings.template_update_delay=0
spring.freemarker.settings.default_encoding=UTF-8
spring.freemarker.settings.classic_compatible=true
spring.freemarker.order=1

 

spring-boot集成Freemarker开发

标签:file   ges   tin   run   localhost   tis   host   cal   set   

原文地址:https://www.cnblogs.com/liyanyan665/p/11257597.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!