angular - 返回 http 400 状态码不起作用
问题描述
每个网页都说这行代码
return new ResponseEntity<Customer>(HttpStatus.BAD_REQUEST);
返回错误代码 400,但是当我强制它时,我得到“405 Method Not Allowed”。为什么?
@PutMapping(value = "/rest/customer/{id}")
public Object updateCustomer(@PathVariable(name = "id") long id,
@RequestBody Customer customer) {
if (id != customer.getId()) {
return new ResponseEntity<Customer>(HttpStatus.BAD_REQUEST);
} else {
解决方案
推荐阅读
- json - ObjectMapper.readValues() 对错误 JSON 输入的奇怪行为
- react-native - 我无法通过按标签栏导航按钮来显示抽屉导航
- sql - 从 SQL 中的国家/地区列表创建固定装置
- apache-spark - pyspark 数据框连接操作和写为 json 很慢
- c++ - 为什么我的 C++ 代码仍在运行?我看不出任何理由
- php - 将 Linux 发行版的版本号解析为 PHP 变量
- sql-server - 在 SQL 中将行转置为列
- fortran - 仅对特定数组索引求和
- mysql - mysql group_concat 评分切片问题
- android - 通过 Android Studio 创建 Flutter 应用程序时出现问题