欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用Jquery獲取Thymeleaf參數(shù)的三種方式小結(jié)

 更新時間:2024年07月30日 10:04:25   作者:成為大佬先禿頭  
在使用Thymeleaf進行數(shù)據(jù)填充的時候,發(fā)現(xiàn)使用jquery原始方式獲取內(nèi)容參數(shù)發(fā)現(xiàn)拿不到數(shù)據(jù),本文主要介紹了使用Jquery獲取Thymeleaf參數(shù)的三種方式小結(jié),感興趣的可以了解一下

在使用Thymeleaf進行數(shù)據(jù)填充的時候,發(fā)現(xiàn)使用jquery原始方式獲取內(nèi)容參數(shù)發(fā)現(xiàn)拿不到數(shù)據(jù)。將百度后看到的解決方案整理下來,僅供參考。

方法一:內(nèi)聯(lián)獲取

<script>標(biāo)簽中 th:inline 一定不能少,通常在取值的前后會加上不同的注釋,不過個人覺得這樣子寫太麻煩了這么多括號!

<p th:text="#{message}">default message</p>
<script th:inline="javascript">
    var message = [[${message}]];
    console.log(message);
</script>

方法二:隱藏域獲取

將參數(shù)放到隱藏域中在獲取

<p th:value="#{message}" type="hidden" id="data">default message</p>
//獲取隱藏域里面的參數(shù)
<script  type="text/javascript">
    var data=${"#data"}.val();
    var data=$("#data").val();
</script>

方法三:text文本獲取

<p th:text="#{message}" id="data"></p>
<script  type="text/javascript">
    var bankCard1=$("#data").text();
</script>

Jquery獲取thymeleaf中checkbox的值

實現(xiàn)

thymeleaf頁面代碼

 <button id="printBtn"  class="btn btn-info  mb_1em" type="button" onclick="return printDetails()"><i class="fa fa-paste"></i> 打印</button>
            <table id="wmsInOrderDetail_table_id"  class="table  table-bordered hover" style="width:100%">
                <thead>
                <tr>
                    <th>序號</th>
                    <th>托盤編號</th>
                    <th>物料編號</th>
                    <th>物料名稱</th>
                    <th>數(shù)量</th>
                    <th>供應(yīng)商批次</th>
                    <th>生產(chǎn)日期</th>
                    <th>狀態(tài)</th>
                </tr>
                </thead>
                <tbody >
                <tr th:each="orderlist:${wmsReceiveOrderDetailsVOList}"  >
                    <td>
                    <input type="checkbox"
                           class="ads_Checkbox"
                           th:text="${orderlist.id}"
                           th:value="${orderlist.id}" name="checkedid"/>
                    </td>
                    <td th:text="${orderlist.salverCode}"></td>
                    <td th:text="${orderlist.materielId}"></td>
                    <td th:text="${orderlist.materielName}"></td>
                    <td th:text="${orderlist.num}"></td>
                    <td th:text="${orderlist.supplierBatch}"></td>
                    <td th:text="${#dates.format(orderlist.productDate, 'yyyy-MM-dd HH:mm:ss')}"></td>
                    <td th:text="${orderlist.statusName}"></td>
                </tr>
                </tbody>
            </table>

選中數(shù)據(jù)后,點擊打印按鈕,來到j(luò)s中的方法。

function printDetails(){
    debugger
    var checkID = [];//定義一個空數(shù)組
    $("input[name='checkedid']:checked").each(function(i){//把所有被選中的復(fù)選框的值存入數(shù)組
        checkID[i] =$(this).val();
    console.log(checkID);
    });
   
}

到此這篇關(guān)于使用Jquery獲取Thymeleaf參數(shù)的三種方式小結(jié)的文章就介紹到這了,更多相關(guān)Jquery獲取Thymeleaf參數(shù)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家! 

相關(guān)文章

最新評論