[英]Controller checkEmail returns “Error parsing JSON: undefined false” for 'false', 'true' works as intended
I've got a little problem with returning false from controller. 我从控制器返回false有一个小问题。 First off, true is being returned normally as "true" in JSON without any problem, but when it should return false this is displayed :
首先,true在JSON中通常以“ true”形式正常返回,没有任何问题,但是当它应返回false时将显示:
Error parsing JSON: undefined
undefined:
false
Here is my DAO 这是我的DAO
@Override
public Boolean checkEmail(String email) {
System.out.println(email);
Query query = em.createQuery("SELECT s FROM StudenciEntity s WHERE s.email LIKE :email");
query.setParameter("email", email);
if (query.getResultList().isEmpty()) {
return false;
}
else {
return true;
}
}
Here is Controller 这是管制员
@RequestMapping(value = "/email/{email:.+}", method = RequestMethod.GET)
public ResponseEntity<Boolean> checkEmail(@PathVariable String email) {
Boolean checkEmail = istudenciService.checkEmail(email);
if (checkEmail !=null) {
return new ResponseEntity<Boolean>(checkEmail, HttpStatus.OK);
}
else {
return new ResponseEntity<Boolean>(HttpStatus.NOT_FOUND);
}
}
At the beginning i was returning Long for email (1 and -1) and it worked, then wanted to make it boolean and all this happened. 刚开始,我返回Long来接收电子邮件(1和-1),并且可以正常工作,然后想将其设置为布尔值,这一切都发生了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.