1.详情见下图

springBoot---优化ftlh

 

 springBoot---优化ftlh

 springBoot---优化ftlh

 

 

 springBoot---优化ftlh

 

 springBoot---优化ftlh

 

 

my:
user: zhangsan
age: 23
spring:
freemarker:
allow-request-override: true
allow-session-override: true
cache: false
check-template-location: true
charset: UTF-8
content-type: text/html;
expose-request-attributes: true
expose-session-attributes: true
expose-spring-macro-helpers: true
template-loader-path: classpath:/templates/,classpath:/static/,classpath:/public/
prefix:
suffix: .ftlh
request-context-attribute: request
settings:
template_update_delay: 0
url_escaping_charset: UTF-8
locale: UTF-8
datetime_format: yyyy-MM-dd HH:mm:ss
date_format: yyyy-MM-dd
time_format: HH:mm:ss
template_exception_handler: html_debug
# 数字格式化,无小数点
number_format: '0.#'
# 设置freemarker标签 0,1,2 0=自动识别,默认1
tag_syntax: 'auto_detect'




<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
我的名字是: ${name}
性别是:${sex}
年龄是:${age}
<#if sex=='0'>

<#elseif sex=='1'>

<#else >
飞哥
</#if>
<#if age gte 18>
已成年
<#else >
未成年
</#if>
<#list userList as user>
${user}
</#list>
</body>
</html>



package demo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Map;

@Controller
public class FreemarkerIndexController {
@RequestMapping("/freemarkerIndex")
public String freemarkerIndex(Map<String,Object> result, HttpServletRequest request){
result.put("name","hello");
result.put("sex","0");
result.put("age",20);
ArrayList<String> userList=new ArrayList<>();
userList.add("小桃子");
userList.add("小丽丽");
result.put("userList",userList);
return "freemarkerIndex";
}
}




package demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
//@ComponentScan("demo")
public class demoApplication {
public static void main(String[] args){
SpringApplication.run(demoApplication.class);
}
}

 

相关文章:

  • 2022-12-23
  • 2022-01-15
  • 2022-12-23
  • 2021-09-17
  • 2022-01-18
  • 2021-11-21
  • 2022-01-19
猜你喜欢
  • 2021-08-26
  • 2021-11-14
  • 2021-04-27
  • 2022-01-10
  • 2021-11-10
  • 2021-07-12
相关资源
相似解决方案