前言:习惯于线路学习法,即通过其中一个场景为例把前后端调用场景梳理出来,再不断丰富各线路上涉及知识点,以满足不同场景的需求。比如前后端交互学习,可以先通过postman工具请求一个方法并成功返回作为一个实践场景,理出其中的线路,并根据线路上的内容展开详细学习,然后把各种实践场景变换出来,最后做实战总结。 第一步:实践场景 第二步:理出线路 第三步:总结知识点并展开详细学习 第四步:总结归纳常用知识点 以分页查询为例 后端接口调用工具postman 线路: 1,请求类型 get、 post 2,请求路径 如:@RequestMapping 3,请求参数 如:@RequestParam 4,参数类型 如:json、java对象 5,返回对象 如:ResponseEntity
其中包含知识点 springMVC http报文
场景:分页查询
1,请求类型 post方式
2,请求路径映射注解 @RequestMapping
3,请求参数注解 @RequestParam
4,参数类型 json、java对象
5,返回对象 ResponseEntity
@RestController
@RequestMapping("authCustomer")
public class AuthCustomerController {
@RequestMapping(value = "queryByPage", method = RequestMethod.POST)
public PageInfo queryByPage(@RequestBody AuthCustomer authCustomer,@RequestParam Integer pageNum,@RequestParam Integer pageSize) {
PageHelper.startPage(pageNum,pageSize);
List<AuthCustomer> list = authCustomerService.queryByPage(authCustomer);
return new PageInfo<>(list);
}
}