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);
    }
    }
  • 相关阅读:
    [BJWC2010]外星联络
    [NOI2015]品酒大会
    工艺 /【模板】最小表示法
    [NOI2016]优秀的拆分
    [HEOI2016/TJOI2016]字符串
    [SDOI2016]生成魔咒
    【模板】后缀自动机 (SAM)【SA解法】
    [湖南集训]图森
    [USACO17DEC]Standing Out from the Herd P
    Annihilate
  • 原文地址:https://www.cnblogs.com/wendy-0901/p/14239882.html
Copyright © 2011-2022 走看看