【springboot+vue前后端分离】之后台接收不到前台的数据

源代码,里面的controller为下面的方法

@ApiOperation(value = "分页讲师列表")
@PostMapping("pageQuery/{page}/{limit}")
public R pageQuery(
    @ApiParam(name = "page", value = "当前页码", required = true)
    @PathVariable Long page,

    @ApiParam(name = "limit", value = "每页记录数", required = true)
    @PathVariable Long limit,

    @ApiParam(name = "teacherQuery", value = "查询对象", required = false)
    TeacherQuery teacherQuery){

    Page<Teacher> pageParam = new Page<>(page, limit);

    teacherService.pageQuery(pageParam, teacherQuery);
    List<Teacher> records = pageParam.getRecords();
    long total = pageParam.getTotal();

    return  R.ok().data("total", total).data("rows", records);
}

结果后端接受不到前端传的参数
这是看到一篇博客
得出结果是

前端发送的数据一直是json格式的,除非是放在路径上的?后面发送过来的,只要是发送的json数据,就只能用@RequestBody接收,我这里是这样改的:

 @ApiOperation(value = "分页讲师列表22222222222")
    @PostMapping("pageQuery/{page}/{limit}")
    public R pageQuery(
            @ApiParam(name = "page", value = "当前页码", required = true)
            @PathVariable Long page,

            @ApiParam(name = "limit", value = "每页记录数", required = true)
            @PathVariable Long limit,

            @ApiParam(name = "teacherQuery", value = "查询对象", required = false)
            @RequestBody TeacherQuery teacherQuery){
        Page<EduTeacher> pageParam = new Page<>(page, limit);

        eduTeacherService.pageQuery(pageParam, teacherQuery);
        List<EduTeacher> records = pageParam.getRecords();
        long total = pageParam.getTotal();

        return  R.ok().data("total", total).data("rows", records);
    }

如图所示
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/he1234555/article/details/115084848
今日推荐