开心一笑: 会买水果的狗狗

    关注微信公众号

    QQ群:831045818

    app下载

    当前位置:首页> java > 技术文档 > 正文
    thymeleaf 引入模板文件
    发布时间:2021-09-06 13:16:19.0 浏览次数:
    footer.html
    
    <div th:fragment="common">
        <select class="selectpicker">
            <option>Mustard</option>
            <option>Ketchup</option>
            <option>Barbecue</option>
        </select>
    </div>
    
    //直接加载
    <th:block th:include="footer :: common" />
    //放到div 里
    <div th:include="footer :: common"></div>

    //footer为路径,以resources/templates/为根目录

    如文件放在 resources/templates/abc/footer.html

    <th:block th:include="/abc/footer :: common" />

    common为th:fragment="common"的common,表示加载这里面的内容

    //传值写法 select 的nane 传source
    <th:block th:include="labelThymeleaf :: common('source')" />
    
    
    //用户th:name="${name}"赋值
    <div th:fragment="common(name)">
        <select th:name="${name}" class="selectpicker">
            <option>Mustard</option>
            <option>Ketchup</option>
            <option>Barbecue</option>
        </select>
    </div>
    
    //正式环境可能报路径错误
    将<th:block th:include="labelThymeleaf :: common('source')" /> 
    写法,改成元素包裹 路径区分大小写并且首行无/
    <span th:include="IpManagement/labelThymeleaf :: commonSource('source')" />


    关注"都市百货" 了解南陵

    微信咨询wanglf2r(不拉群 发广告者勿加)

    0
    0
    上一篇:南陵博文中学2021年军训营 上一篇:南陵县家发镇:大力整治出店经营

    评论已有0

    提交评论

    热门评论

    南陵新闻
    公示公告
    常用查询
    风光南陵
    走出南陵
    友情链接