Error: Request failed with status code 400

目录

GET http://localhost:8080/category/list 400

后端没有报错信息 ,相应请求控制器打断点也不进。 
经查阅发现 400问题,最大几率是出现了数据类型不一致的问题 。
也就是说如下图代码中,前端要么没有传名为type的数据,要么传了但是数据类型与服务端不一致,接收不成功,
导致报错。

而查看此次前端发的请求URL可以得知,前端没有携带名为type的数据,导致请求没有进入控制器。

在这里插入图片描述

解决方法:
可将@RequestParam("type")去掉 , 若前端携带了名为type的参数,会自动赋值。 
  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Uniapp is a framework that allows developers to create cross-platform applications using HTML, CSS, and JavaScript. In order to make requests in a Uniapp application, developers can use the built-in uni.request method. Here's an example of how to make a simple GET request using uni.request: ``` uni.request({ url: 'https://jsonplaceholder.typicode.com/todos/1', success: (res) => { console.log(res.data) }, fail: (err) => { console.log(err) } }) ``` In this example, we're making a request to the JSONPlaceholder API to retrieve a todo item with an ID of 1. The uni.request method takes an object as its argument, with various properties that can be set: - `url`: The URL to make the request to. - `method`: The HTTP method to use (default is GET). - `data`: The data to send with the request (for POST, PUT, etc.). - `header`: Additional headers to send with the request. - `dataType`: The expected data type of the response (e.g. JSON). - `success`: A function to be called if the request is successful. - `fail`: A function to be called if the request fails. In our example, we're only setting the `url` property and the `success` and `fail` callbacks. When the request is successful, the `success` callback is called with the response data as its argument. If the request fails, the `fail` callback is called with an error object as its argument. Uniapp also provides other methods for making requests, such as `uni.uploadFile` for uploading files, and `uni.downloadFile` for downloading files. These methods work similarly to `uni.request`, but with additional options specific to their use cases.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值