@ResponseBody
2017-12-27 本文已影响0人
简约_7e45
-
@ResponseBody
使用这个注解的时候,Spring会默认把对象转换成json返回
但是集成的时候需要注意一下几点:
如果运行报错:nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/util/DefaultIndenter
请添加依赖
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.8.7</version>
</dependency>
具体参考:http://blog.csdn.net/lq1997127/article/details/72866386