springcloud controller返回数据不是json格式二十XML格式

客户端服务依赖


    org.springframework.cloud
    spring-cloud-starter-eureka-server

controller写法

@RequestMapping(value = "/getMessage")
public Object getMessage(){
    ResponseBody responseBody = new ResponseBody();
    responseBody.setData("i got you v1");
    responseBody.setCode("200");
    return responseBody;
}

实际界面看到的数据:

200

i got you v1

更改依赖


    org.springframework.cloud
    spring-cloud-starter-eureka

controller写法不变,返回格式则为json格式

{"message":null,"code":"200","error":null,"data":"i got you v1"}

参考自:https://blog.csdn.net/weixin_44520652/article/details/86477160

你可能感兴趣的:(springcloud controller返回数据不是json格式二十XML格式)