springboot+thymeleaf+mybatis逆向工程和pageHelper

Posted LDarkHorse

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springboot+thymeleaf+mybatis逆向工程和pageHelper相关的知识,希望对你有一定的参考价值。

thymeleaf-+按钮:

  前端:

  html:

                                        <td  style="vertical-align:middle" th:text="${product.price}"></td>
                                        <td  style="vertical-align:middle">
                                            <span style="margin:5px;padding-left:5px;padding-right: 5px;border:1.5px solid #ccc;" th:onclick="|javascript:jian(this,${product.id})|">-</span>
                                            <span th:text="${product.quantity}"></span>
                                            <span style="margin:5px;padding-left:5px;padding-right: 5px;border:1.5px solid #ccc;" th:onclick="|javascript:jia(this,${product.id})|">+</span>
                                        </td>

  js:

    //增加:
    function jia(obj,productId) {
        var button =$(obj);//表示当前按钮
        var numButton=button.prev();
        //获取购物车商品总额:
        var sumPricePre = button.parent().parent().children("td").eq(3);
        var sumPrice = sumPricePre[0].textContent;
        sumPrice = parseInt(sumPrice);
        var num=numButton.text();
        num=parseInt(num);
        //与数据库通信:
        //发送\'+\'的请求
        $.ajax({
            url:"/addShop/"+productId,
            success:function(data){
                if(data.trim()=="failed"){
                    alert("操作失败!");
                }else{
                    num++;
                    data = parseInt(data);
                    sumPrice+=data;
                    sumPricePre[0].textContent = sumPrice;
                    numButton.text(num);
                }
            }
        });
    }
    //减少:
    function jian(obj,productId){
        var button=$(obj);
        var numButton=button.next();
        var num=numButton.text();
        num=parseInt(num);

        //获取购物车商品总额:
        var sumPricePre = button.parent().parent().children("td").eq(3);
        var sumPrice = sumPricePre[0].textContent;
        sumPrice=parseInt(sumPrice);
        //得到单件商品的价格:
        var price = sumPrice/num;

        if(num==1){
            return;
        }

        $.ajax({
            url:"/reduceShop/"+productId,
            success:function(data){
                if(data.trim()=="failed"){
                    alert("操作失败!");
                }else{
                    num--;
                    sumPrice-=price;
                    sumPricePre[0].textContent = sumPrice;
                    numButton.text(num);
                }
            }
        });

    }

以上是关于springboot+thymeleaf+mybatis逆向工程和pageHelper的主要内容,如果未能解决你的问题,请参考以下文章

SpringBoot——SpringBoot集成Thymeleaf

springboot 中使用thymeleaf

SpringBoot系列之集成Thymeleaf用法手册

SpringBoot :thymeleaf 使用详解

springboot-thymeleaf

springboot:thymeleaf使用详解