Java 如何在ResponseEntity中返回布尔值?

Java 如何在ResponseEntity中返回布尔值?,java,spring-boot,controller,repository,Java,Spring Boot,Controller,Repository,控制器代码如下所示: @PutMapping("/update-student") public ResponseEntity<Student>updateStudent(@RequestBody Student student)throws Exception{ boolean getStudent = studentService.updateStudent(student); return new ResponseEntity<Student>(getStu

控制器代码如下所示:

@PutMapping("/update-student")
public ResponseEntity<Student>updateStudent(@RequestBody Student student)throws Exception{
  boolean getStudent = studentService.updateStudent(student);
  return new ResponseEntity<Student>(getStudent,HttpStatus.OK);
}
@PutMapping(“/update student”)
public ResponseEntityupdateStudent(@RequestBody Student)引发异常{
布尔getStudent=studentService.updateStudent(学生);
返回新的ResponseEntity(getStudent,HttpStatus.OK);
}

您正在返回类型为
学生的
响应性
响应性

为了回报布伦,你必须做如下的事情
ResponseEntity

返回布尔值的用例是什么?如果你想返回
false
如果学生的保存/更新失败,你最好返回一个错误代码。