zoukankan      html  css  js  c++  java
  • 数据展示

    <!DOCTYPE html>
    <html xmlns:th="http://www.thymeleaf.org">
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
    
    </body>
    </html>

    普通的Java字符串

    model.addAttribute("javaString", "simple java string");
    <p th:text="${javaString}" />

    HTML代码字符串

    model.addAttribute("labelString","<span style='color:red'>Jerry</span>");
    <p th:utext="${labelString}" />

    Java对象

    Demo demo = new Demo("弦乐", 12, new Date());
    model.addAttribute("demo", demo);
    <div>显示对象:方式一</div>
    <div>
        <p th:text="'字符串:'+${demo.stringField}" />
        <p th:text="'整数:'+${demo.intField}" />
        <p th:text="'日期:'+${#dates.format(demo.dateField,'yyyy-MM-dd')}" />
    </div>
    <br />
    <div>显示对象:方式二</div>
    <div th:object="${demo}">
        <p th:text="'字符串:'+*{stringField}" />
        <p th:text="'整数:'+*{intField}" />
        <p th:text="'日期:'+*{#dates.format(dateField,'yyyy-MM-dd')}" />
    </div>

    List<String>

    List<String> stringList = new ArrayList<>(4);
    stringList.add("huang0");
    stringList.add("chen");
    stringList.add("hello");
    stringList.add("xian");
    model.addAttribute("stringList",stringList);
    <div>遍历List-str</div>
    <table border="1">
        <thead>
        <th>value</th><th>odd</th><th>even</th><th>count</th><th>current</th><th>first</th><th>index</th><th>last</th><th>size</th>
        </thead>
        <tbody>
            <tr th:each="s,l:${stringList}" >
                <td th:text="${s}"/>
                <td th:text="${l.odd}"/>
                <td th:text="${l.even}"/>
                <td th:text="${l.count}"/>
                <td th:text="${l.current}"/>
                <td th:text="${l.first}"/>
                <td th:text="${l.index}"/>
                <td th:text="${l.last}"/>
                <td th:text="${l.size}"/>
            </tr>
        </tbody>
    </table>

    List<Object>

    List<Demo> demoList = new ArrayList<>(3);
    demoList.add(demo);
    demoList.add(demo);
    model.addAttribute("demoList", demoList);
    <div>遍历List-obj</div>
    <table border="1">
        <thead>
        <th>stringField</th><th>intField</th><th>stringField</th>
        <th>odd</th><th>even</th><th>count</th><th>current</th><th>first</th><th>index</th><th>last</th><th>size</th>
        </thead>
        <tbody>
        <tr th:each="d,l:${demoList}" >
            <td th:text="${d.stringField}"/>
            <td th:text="${d.intField}"/>
            <td th:text="*{#dates.format(d.dateField,'yyyy-MM-dd')}"/>
            <td th:text="${l.odd}"/>
            <td th:text="${l.even}"/>
            <td th:text="${l.count}"/>
            <td th:text="${l.current}"/>
            <td th:text="${l.first}"/>
            <td th:text="${l.index}"/>
            <td th:text="${l.last}"/>
            <td th:text="${l.size}"/>
        </tr>
        </tbody>
    </table>

    Set<String>

    Set<String> stringSet = new HashSet<>();
    stringSet.add("huang0");
    stringSet.add("chen");
    stringSet.add("hello");
    stringSet.add("xian");
    model.addAttribute("stringSet", stringSet);
    <div>遍历Set-str</div>
    <table border="1">
        <thead>
        <th>value</th><th>odd</th><th>even</th><th>count</th><th>current</th><th>first</th><th>index</th><th>last</th><th>size</th>
        </thead>
        <tbody>
        <tr th:each="s,l:${stringSet}" >
            <td th:text="${s}"/>
            <td th:text="${l.odd}"/>
            <td th:text="${l.even}"/>
            <td th:text="${l.count}"/>
            <td th:text="${l.current}"/>
            <td th:text="${l.first}"/>
            <td th:text="${l.index}"/>
            <td th:text="${l.last}"/>
            <td th:text="${l.size}"/>
        </tr>
        </tbody>
    </table>

    Set<Object>

    Set<Demo> demoSet = new HashSet<>();
    demoSet.add(demo);
    demoSet.add(new Demo("hello", 22, new Date())); 
    model.addAttribute("demoSet", demoSet);
    <div>遍历Set-obj</div>
    <table border="1">
        <thead>
        <th>stringField</th><th>intField</th><th>stringField</th>
        <th>odd</th><th>even</th><th>count</th><th>current</th><th>first</th><th>index</th><th>last</th><th>size</th>
        </thead>
        <tbody>
        <tr th:each="d,l:${demoSet}" >
            <td th:text="${d.stringField}"/>
            <td th:text="${d.intField}"/>
            <td th:text="*{#dates.format(d.dateField,'yyyy-MM-dd')}"/>
            <td th:text="${l.odd}"/>
            <td th:text="${l.even}"/>
            <td th:text="${l.count}"/>
            <td th:text="${l.current}"/>
            <td th:text="${l.first}"/>
            <td th:text="${l.index}"/>
            <td th:text="${l.last}"/>
            <td th:text="${l.size}"/>
        </tr>
        </tbody>
    </table>

    Map<String, String>

    Map<String, String> stringMap = new HashMap<>(3);
    stringMap.put("name", "world");
    stringMap.put("sex", "1");
    stringMap.put("age", "12");
    model.addAttribute("stringMap", stringMap);
    <div>遍历Map-str-str</div>
    <table border="1">
        <thead>
        <th>key</th><th>value</th>
        <th>odd</th><th>even</th><th>count</th><th>current</th><th>first</th><th>index</th><th>last</th><th>size</th>
        </thead>
        <tbody>
        <tr th:each="e,l:${stringMap}" >
            <td th:text="${e.key}"/>
            <td th:text="${e.value}"/>
            <td th:text="${l.odd}"/>
            <td th:text="${l.even}"/>
            <td th:text="${l.count}"/>
            <td th:text="${l.current}"/>
            <td th:text="${l.first}"/>
            <td th:text="${l.index}"/>
            <td th:text="${l.last}"/>
            <td th:text="${l.size}"/>
        </tr>
        </tbody>
    </table>

    Map<String, Object>

    Map<String, Demo> demoMap = new HashMap<>(2);
    demoMap.put("demo01", demo);
    demoMap.put("demo02", new Demo("hello", 22, new Date()));
    model.addAttribute("demoMap", demoMap);
    <div>遍历Map-str-obj</div>
    <table border="1">
        <thead>
        <th>key</th><th>stringField</th><th>intField</th><th>stringField</th>
        <th>odd</th><th>even</th><th>count</th><th>current</th><th>first</th><th>index</th><th>last</th><th>size</th>
        </thead>
        <tbody>
        <tr th:each="e,l:${demoMap}" >
            <td th:text="${e.key}"/>
            <td th:text="${e.value.stringField}"/>
            <td th:text="${e.value.intField}"/>
            <td th:text="*{#dates.format(e.value.dateField,'yyyy-MM-dd')}"/>
            <td th:text="${l.odd}"/>
            <td th:text="${l.even}"/>
            <td th:text="${l.count}"/>
            <td th:text="${l.current}"/>
            <td th:text="${l.first}"/>
            <td th:text="${l.index}"/>
            <td th:text="${l.last}"/>
            <td th:text="${l.size}"/>
        </tr>
        </tbody>
    </table>

  • 相关阅读:
    GCD介绍(二): 多核心的性能
    GCD介绍(一): 基本概念和Dispatch Queue
    iOS 中如何监测某段代码运行的时间
    DSOframer 无法正常加载的解决方案
    Hexo 官方主题 landscape-plus 优化
    在 Parallels Desktop 中,全屏模式使用 Win7,唤醒时黑屏
    VS2015 企业版不支持 JavaScript 语法高亮、智能提醒
    解决 Boot Camp 虚拟机升级到 Windows 10 后 Parallels Desktop 不能识别的问题
    利用SkyDrive Pro 迅速批量下载SharePoint Server 上已上传的文件
    SharePoint Server 2013 让上传文件更精彩
  • 原文地址:https://www.cnblogs.com/517cn/p/10977381.html
Copyright © 2011-2022 走看看