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获取属性参数

 

 







posted @ 2019-09-28 04:42  岑惜  阅读(801)  评论(0编辑  收藏  举报