• 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);
    }
    }
  • 相关阅读:
    PIC18F2455/2550/4455/4550之通用串行总线USB
    今天,一个新的起点
    WM_COPYDATA消息
    图片浏览(附带样式+效果)
    这条路,走远一点,再远一点
    html之table(10种表格)
    数据导出成Excel
    .net 附件下载
    .net Repeater嵌套的数据绑定问题
    AjaxPro.2.dll的使用方法,以实例讲解。
  • 原文地址:https://www.cnblogs.com/wendy-0901/p/14239882.html
Copyright © 2020-2023  润新知