jquery 我想显示从数据库到卡片的学生人数

bvjveswy  于 2022-11-03  发布在  jQuery
关注(0)|答案(1)|浏览(134)

学生控制器

@GetMapping("/numberStudent")
    @ResponseBody
    public String getStudentNumber(){
        String repot = null;
        repot = studentRepository.StudentsNBR();
        return repot;
    }

Studeent存储库

@Query("select count(e) from Student ")
    public String StudentsNBR();

所以基本上我想用bootstrap在卡片上显示学生的号码

<div class="col-sm">
                <div class="card bg-light" style="width: 18rem;">
                    <img class="card-img-top" src="https://cdn.discordapp.com/attachments/557595531526799390/1033961333584052224/spring.gif"
                        style="height: 180px;">
                    <div class="card-body">
                    <div class="p-1 mb-2 bg-dark text-white">
                        <h5 class="card-title" align="center">Spring BOOT</h5></div>
                        <script>
                        jQuery(function($) {$.number( 1234.5678, 2 );
            $.ajax({
                type : "GET",
                url : "/numberStudent"});
                </script>
                    </div>
                </div>

            </div>
inb24sb2

inb24sb21#

只需添加模型接口并创建一个保存返回值的变量,

model.AddAttribute("var_name",var_name);

然后转到视图并将其命名为[th:text=${"variable-name"}]

相关问题