简体   繁体   English

控制器checkEmail为“ false”返回“错误解析JSON:undefined false”,“ true”按预期工作

[英]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.

相关问题 获取Json返回true或false - Getting Json returns true or false 使用Jackson JSON解析为布尔值为TRUE或FALSE - TRUE or FALSE into boolean using Jackson JSON parsing JSON 错误我无法修复?? (期待 &#39;STRING&#39;, &#39;NUMBER&#39;, &#39;NULL&#39;, &#39;TRUE&#39;, &#39;FALSE&#39;, &#39;{&#39;, &#39;[&#39;, got &#39;undefined&#39;) - JSON error I can't fix?? (Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined') 我如何修复以下 json 错误 Expecting &#39;STRING&#39;, &#39;NUMBER&#39;, &#39;NULL&#39;, &#39;TRUE&#39;, &#39;FALSE&#39;, &#39;{&#39;, &#39;[&#39;, got &#39;undefined&#39; - how can i fix the following json error Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined' JSON 架构错误期望 'STRING'、'NUMBER'、'NULL'、'TRUE'、'FALSE'、'{'、'[',使用正则表达式得到 'undefined' - JSON schema error Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined' with a Regex 即使条件为真,PHP 验证总是在 ajax 中返回错误/假 - PHP validation always returns error/false in ajax even the conditions are true 如何将 RF 中的布尔值(真/假)转换为 Json 中的布尔值(真/假) - How to convert boolean(True/False) in RF to boolean(true/false) in Json JSON密钥存在,但返回false - JSON key exists but returns false AJAX JSON解析返回false - AJAX JSON parse returns false json_encode() 返回 false - json_encode() returns false
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM