thymeleaf的th:href传参、th:onclick传参、th:fragment传参

2020-06-03 10:54:44 1835

th:href传参

直接将参数放到括号里面,th:href跳转需要使用@{},获取后台传来的值使用${}

<a th:href="@{/toEditMemorandum(id=${memorandum?.id?:'-1'})}" target="_blank"></a>

th:onclick传参

这个需要使用|将参数包括起来

<button th:onclick="|toShow(${bCategoryId})|"></button>

th:fragment传参

<th:block th:insert="~{modules/website/common/mods-common :: menuPanelChoose('false')}" th:fragment="menu-panel"></th:block>
<th:block th:insert="~{modules/website/common/mods-common :: menuPanelChoose('true')}" th:fragment="menu-panel-index"></th:block>

<div class="fly-panel fly-column" th:fragment="menuPanelChoose(needSearch)">
    <div class="layui-container">
        <ul class="layui-clear">
            <li class="layui-hide-xs layui-this"><a th:href="@{/}">首页</a></li>
        </ul>
        <div class="fly-column-right layui-hide-xs">
            <th:block th:if="${needSearch=='true'}">
                <input type="text" class="layui-input searchVal" placeholder="请输入搜索的内容" style="display: inline-block;width: auto">
                <span class="fly-search" style="margin-left: -50px;"><i class="layui-icon"></i></span>
            </th:block>
            <a th:href="@{/blogArticle/addView}" class="layui-btn" target="_blank">发表博客</a>
        </div>
    </div>
</div>


相关文章

分类

{{name}}

标签

{{name}}

相关文章

广告区域
没有相关数据