zoukankan      html  css  js  c++  java
  • springBoot---优化ftlh

    1.详情见下图

     

     

     

     

    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);
    }
    }
  • 相关阅读:
    TCP三次握手(建立连接)/四次挥手(关闭连接)
    STL
    Hadoop- 集群时间同步
    Hadoop- MapReduce在实际应用中常见的调优
    Hadoop- HDFS的Safemode
    Hadoop- 分布式资源管理YARN架构讲解
    Hadoop- Hadoop详解
    Linux- Linux自带定时调度Crontab使用详解
    Spark- Spark Yarn模式下跑yarn-client无法初始化SparkConext,Over usage of virtual memory
    Zeppelin- Linux下安装Zeppelin
  • 原文地址:https://www.cnblogs.com/wendy-0901/p/14239882.html
Copyright © 2011-2022 走看看