美文网首页Java 杂谈
二,Spring Boot基于MySQL,MyBatis配置Fr

二,Spring Boot基于MySQL,MyBatis配置Fr

作者: Wocus | 来源:发表于2018-09-25 15:07 被阅读0次
Spring Boot里面有很多的模板供我们使用,我简单介绍下FreeMarker的集成

gradle文件加入此配置

compile('org.springframework.boot:spring-boot-starter-freemarker')

application.yml加入此配置

 #    freemarker静态资源配置
spring:
    freemarker:
        tempalte-loader-path: classpath:/templates
        cache: false
        charset: UTF-8
        check-template-location: true
        content-type: text/html
        expose-request-attributes: true
        expose-session-attributes: true
        request-context-attribute: request
        suffix: .html

在Controller配置入口,Spring Boot有两种@RectController,@Controller,前者是为ResponseBody返回的,就不需要每个方法注解返回Body,我们需要返回的是视图,类名上注解@Controller,方法体注释@RequestMapper("/name")就行了,如下图


image.png

返回的user是resources/templates下的一个html文件

配置完毕

相关文章

网友评论

    本文标题:二,Spring Boot基于MySQL,MyBatis配置Fr

    本文链接:https://www.haomeiwen.com/subject/eykloftx.html