- 需求的场景描述(希望解决的问题)
java后台这样写的。
List catelist = ahCategoryService.getCategoryList();
super.getResponse().setContentType(“text/json;charset=UTF-8”);
PrintWriter out;
try {
out = super.getResponse().getWriter();
out.print(catelist);
out.close();
} catch (IOException e) {
e.printStackTrace();
}
小程序里这样写的
wx.request({
url: ‘http://localhost/xaahzz/index/indexView!indexView.action’,
data: {},
method: ‘POST’,
header: { “Content-Type”: “application/x-www-form-urlencoded” },
success: function (sessionRes) {
that.setData({
categoryList: sessionRes.data
});
}
});
console.log打出来是[{imgPath=wxImagesCenter/4.jpg, cateId=4, cateName=健康食品}, {imgPath=wxImagesCenter/1.jpg, cateId=3, cateName=个人护理}, {imgPath=wxImagesCenter/3.jpg, cateId=2, cateName=美容护肤}]
看着没问题,但是实际上就是一个字符串,不是数组,怎么办?