Thymeleaf Spring添加动态内容而不替换静态内容

时间:2013-11-21 06:20:59

标签: spring thymeleaf

我有一个网页模板,我想重复使用那个html代码作为模板放在所有页面中。在我的目标页面中,我有一些静态HTML代码

div id="someID">
<table id="test"></table>
</div>

我想使用th:include标签将这个div someID替换为包装div,但这将取代我不想要的someID div的所有内容。我只是想在不替换静态数据的情况下注入新代码 我的模板页面

<div id="wrapper" th:fragment="wrapper" >

1 个答案:

答案 0 :(得分:0)

<div class="control-group" th:fragment="buttons (frag)">
    <div class="controls" th:include="this :: ${frag}"></div>
</div>


        <div th:include="/templates/controls.html :: buttons('buttons')">
            <div th:fragment="buttons">
                <input type="submit" id="proceed" name="_eventId_proceed"
                    th:value="#{proceed}" value="Proceed!" class="btn btn-default" />
                <input type="submit" id="cancel" name="_eventId_cancel"
                    th:value="#{cancel}" value="Cancel!" class="btn btn-default"/>
            </div>  
        </div>