1、加入三个Jar包

springmvc之返回json类型的数据给前端

2、为方法加上@ResponseBody注解,方法直接返回相关信息。

使用ResponseBody注解需要在springmvc.xml文件中配置:

<mvc:annotation-driven></mvc:annotation-driven>
    @ResponseBody
    @RequestMapping("/testJson")
    public Collection<Employee> testJson() {
        return employeeDao.getAll(); 
    }

相关文章:

  • 2021-05-04
  • 2021-09-10
  • 2022-01-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-12
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
  • 2022-03-03
  • 2022-01-17
相关资源
相似解决方案