测试环境
下载Postman测试软件https://www.postman.com/downloads/
项目测试
测试StudentController中的所有方法,注意提交方式的对应。
1.查询所有学生对象
@GetMappingpublic List<Student>listAllStudents(){return studentService.queryAllStudents();}
2.查询单个学生对象
将参数绑定在路径上@PathVariable。
@GetMapping("/{id}")public StudentloadStudentById(@PathVariable int id){return studentService.queryOneById(id);}
3.添加单个学生对象
将参数绑定在请求体上@RequestBody。
@PostMappingpublic booleanaddStudent(@RequestBody Student student){return studentService.addStudent(student);}
数据库:
4.修改学生对象
将参数绑定在请求体上@RequestBody。
@PostMappingpublic booleanaddStudent(@RequestBody Student student){return studentService.addStudent(student);}
数据库:
5.删除学生对象
将参数绑定在路径上@PathVariable。
@DeleteMapping("{id}")public booleandeleteStudentById(@PathVariable int id){return studentService.deleteStudentById(id);}
数据库: