SpingMVC返回Json对象类型报异常

使用SpringMVC返回Json对象时,报 org.springframework.http.converter.HttpMessageNotWritableException: No converter found for return value of type 异常

    public @ResponseBody BaseResult login(String username, String password, String vercode) throws Exception {
        BaseResult br = new BaseResult();
        Manager manager = managerService.findByUsernameAndPassword(username,password);
        if (manager==null){
            br = new BaseResult("Error","用户名或密码错误");
        }
        return br;
    }

图片说明

原因是,SpinGMVC无法将对象直接转换为Json对象,因此需要添加依赖。

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.9.5</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-annotations</artifactId>
      <version>2.9.5</version>
    </dependency>
全部评论

相关推荐

认真搞学习:28小登的建议,投算法岗不要写什么物理竞赛,互联网+,多写点项目,用什么算法做了什么。还有本科算法是不可能的开发你这个也没有项目啊
点赞 评论 收藏
分享
码农索隆:想看offer细节
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务