一.axios是基于promise对ajax的一种封装
1.首先进入官网导入CDN:
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
2.根据后台的controller层的CRUD接口调用:
我们以全查询为例:
@CrossOrigin为跨域资源共享注解切记加上
//全查询
@CrossOrigin
@GetMapping("/findAll")
@ResponseBody
public Map findAll(){
Map map=new HashMap();
List<Studentinfo> studentinfos = studentinfoMapper.selectList(null);
map.put("code",0);
map.put("msg","");
map.put("count",0);
map.put("data",studentinfos);
return map;
}
直接使用接口访问显示Json数据