spring的返回json数据给前端注意事项
1.
记得加入SpringJSON解析包,否则spring无法将返回的pojo类解析成json数据
maven则加上下面的依赖包
<!-- SpringJSON解析包-->
<jackson.version>2.9.9</jackson.version>
.
.
.
.
.
.
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
2.
记得将数据类型改为
dataType: 'json',
否则只能把返回data识别为字符串,无法通过data.xxx获取属性参数
本文来自博客园,作者:岑惜,转载请注明原文链接:https://www.cnblogs.com/c2g5201314/p/11601291.html
响应开源精神相互学习,内容良币驱除劣币