spring.datasource.username=root
spring.datasource.password=1234
spring.datasource.url=jdbc:mysql://localhost:3306/t202?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
//新版的驱动连接老版的数据库时要配Unicode
#模板引擎freemark配置
spring.freemarker.allow-request-override=false
spring.freemarker.request-context-attribute=req
spring.freemarker.suffix=.ftl
spring.freemarker.content-type=text/html;charset=utf-8
spring.freemarker.enabled=true
spring.freemarker.cache=false
spring.freemarker.template-loader-path=classpath:/templates/
spring.freemarker.charset=UTF-8
spring.freemarker.number_format=0.##
在springboot自动生成的**application.java中
列如:
package com.yps;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
//扫描mapper的注解
@MapperScan(basePackages = "com.yps.mapper")
@SpringBootApplication
public class Springboot03Application {
public static void main(String[] args) {
SpringApplication.run(Springboot03Application.class, args);
}
}
注:springboot的模板引擎 tempate html、ftl…都放在这个文件夹,要通过控制器访问才能访问到,直接访问*.html访问不到.*
页面取值
${uname}
逻辑
${uname!"hhhh"} <!--如果没有取到uname值那么就显示hhhh-->
${uname!} <!--如果没有就不显示-->
if
<# if state=="0"> <!--state:属性(填自己要判断的属性)-->
<# else if state=="1">
<# if>
迭代
<# List arr as li >
${li}
</# List>