请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

浏览器访问http://127.0.0.1:9000/business/admin/chapter/list?page=1&size=1出现http状态码400

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Tue Jul 19 10:29:44 CST 2022

There was an unexpected error (type=Bad Request, status=400).

Required request body is missing: public com.course.server.dto.PageDto com.course.business.controller.admin.ChapterController.list(com.course.server.dto.PageDto)

org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public com.course.server.dto.PageDto com.course.business.controller.admin.ChapterController.list(com.course.server.dto.PageDto)

vue:

<script>
export default {
  name: "chapter",
  data:function () {
    return {
      chapters:[]
    }
  },
  mounted: function() {
    let _this = this;
    _this.list();
    //sidebar 激活样式 方式一
    // this.$parent.activeSidebar("business-chapter-sidebar");

  },
  methods: {
    list() {
      let _this = this;
      _this.$ajax.post('http://127.0.0.1:9000/business/admin/chapter/list', {
        page: 1,
        size: 1
      }).then((response)=>{
        console.log("查询大章列表结果:", response);
        _this.chapters = response.data.list;
      })
    }
  }
}
</script>

ChapterController

@RestController
@RequestMapping("/admin/chapter")
public class ChapterController {

    private static final Logger LOG = LoggerFactory.getLogger(ChapterController.class);

    @Resource
    private ChapterService chapterService;

    @RequestMapping("/list")
    public PageDto list(@RequestBody PageDto pageDto) {
        LOG.info("pageDto: {}", pageDto);
        chapterService.getList(pageDto);
        return pageDto;
    }
}

正在回答

2回答

不能直接在浏览器访问:http://127.0.0.1:9000/business/admin/chapter/list?page=1&size=1,这种方式的参数是拼在url里的,不是放在request body里,所以后端接收不到参数,就会报错:Required request body is missing:

1 回复 有任何疑惑可以回复我~
  • 提问者 慕圣4596589 #1
    非常感谢!
    回复 有任何疑惑可以回复我~ 2022-07-19 17:00:03
super_小小胡 2022-07-19 00:32:48
9000端口是网关吧,你确定热部署重启成功了嘛
下载视频          
0 回复 有任何疑惑可以回复我~
  • 提问者 慕圣4596589 #1
    还是不行,浏览器访问http://localhost:8080/business/chapter倒是能正常显示
    回复 有任何疑惑可以回复我~ 2022-07-19 01:01:21
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信