Spring Typecast ArrayList到ResponseEntity
我在向ResponseEntity键入ArrayList时面临一个问题。我对数据库进行本机查询调用以获取结果集。获得结果集后,我将arraylist类型转换为ResponseEntity,以便获得httpStatusCode来构建响应。但是打字给我带来了一个错误。 下面是代码片段Spring Typecast ArrayList到ResponseEntity,spring,spring-mvc,casting,http-status-codes,Spring,Spring Mvc,Casting,Http Status Codes,我在向ResponseEntity键入ArrayList时面临一个问题。我对数据库进行本机查询调用以获取结果集。获得结果集后,我将arraylist类型转换为ResponseEntity,以便获得httpStatusCode来构建响应。但是打字给我带来了一个错误。 下面是代码片段 @Override public ResponseEntity<List<Student>> getAllStudentEnquiry() { logger.info("Getting
@Override
public ResponseEntity<List<Student>> getAllStudentEnquiry() {
logger.info("Getting all student enquiry details");
ResponseEntity<List<SmsEnquiry>> studentList= (ResponseEntity<List<SmsEnquiry>>) smsEnquiryRespository.findAll();
return studentList;
}
@覆盖
公共响应GetAllStudenteQuery()的公共响应{
logger.info(“获取所有学生查询详情”);
ResponseEntity studentList=(ResponseEntity)smsenquiryResposition.findAll();
返回学生名单;
}
我只想从这个响应中得到httpStatus,以决定我构建的响应。
请帮忙
ResponseEntity<List<SmsEnquiry>> studentList = new ResponseEntity<>(smsEnquiryRespository.findAll(),HttpStatus.OK);
ResponseEntity studentList=新的ResponseEntity(smsEnquiryRespository.findAll(),HttpStatus.OK);