Java后台 后台如何向小程序前端传递String字符串?

小程序 文章 2022-03-15 12:00 742 0 全屏看文

AI助手支持GPT4.0

Java后台 后台如何向小程序前端传递String字符串?Java backend How does the backend pass String strings to the front end of the applet?

Java后台 后台如何向小程序前端传递String字符串?

希望同时传递数组对象和一个字符串,直接写成json格式,后台获取数据时打印显示undefined

You want to pass an array object and a string at the same time and write it directly in JSON format. When you get the data in the background, it will print and display undefined

回答:

나의 작은 행운:

不好意思 没有描述清楚,具体如下 :前端(微信小程序) wx.request({ url:***,method:get ,data:openid,success:function(result){ console.log(result.data.teamname)}}) 前端打印出来时undefined[result中显示data已经北转化为字符串],因为后台直接传递的字符串。后端(java后台):List<teamlist> team=teamservice.getteanmlist()[数组对象];String teamname=team.getTeanname()[字符串];JSONArray teamlist=JSONArray.fromObject(team);String teamarrray=teamlist.toString();Stirng jsonstr="{teamlist":"+teamarrray+","teamname":"+teamname+"}"[将字符串与数组对象同时传递] out.write(jsonstr)。

想要问如何同时传递数组对象和字符串,同时前端能够获取且打印(console)出来不会显示undedfinded.

下渝州:

接的啥 打的啥 谁传递 谁接收

Mr.Zhao:

后台是返回还是获取啊,说不清楚

-EOF-

AI助手支持GPT4.0