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>
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-04 14:35
点赞 评论 收藏
分享
头顶尖尖的程序员:我是26届的不太懂,25届不应该是找的正式工作吗?为什么还在找实习?大四还实习的话是为了能转正的的岗位吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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