springmvc使用json数据传递到bootstrap分页数据

2025-07-25 23:52:35

1、服务器将查出的数据,以json字符串的形式返回给浏览器

springmvc使用json数据传递到bootstrap分页数据

3、在pom.xml中加入jackson依赖包。 <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.8.8</version> </dependency>

springmvc使用json数据传递到bootstrap分页数据

5、访问http://localhost:8080/ssm-crud2/emps,查看json数据是否正确返回。

springmvc使用json数据传递到bootstrap分页数据

7、重新修改控制层返回数据的方法:package com.gwolf.crud.controller;import java.util.List;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.bind.annotation.ResponseBody;import com.github.pagehelper.PageHelper;import com.github.pagehelper.PageInfo;import com.gwolf.crud.bean.Employee;import com.gwolf.crud.bean.Msg;import com.gwolf.crud.service.EmployeeService;@Controllerpublic class EmployeeController { @Autowired EmployeeService employeeService; @RequestMapping("/emps") @ResponseBody public Msg getEmpsWithJson(@RequestParam(value="pn",defaultValue="1") Integer pn,Model model) { PageHelper.startPage(pn, 5); List<Employee> employees = this.employeeService.getAll(); //传入连续显示的页数 PageInfo<Employee> pageInfo = new PageInfo<Employee>(employees,5); return Msg.success().add("pageInf", pageInfo); }}

springmvc使用json数据传递到bootstrap分页数据
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
相关推荐
  • 阅读量:35
  • 阅读量:82
  • 阅读量:41
  • 阅读量:75
  • 阅读量:67
  • 猜你喜欢