Number3微信小程序获取springboot数据(仅记录)
GET请求呦
这个就是需要制作模拟器,将需要的数据两方联调
首先准备工作

1、微信端 js
wx.request({
url: 'http://localhost:8080/text/auth/getAllData',
data: {
"startTime": this.data.dateStart,
"endTime": this.data.dateEnd
},
success: (res) => {
console.log(res);
this.setData({
htruck: res.data.htruck
});
},
fail: (res) => {
console.log(res.errMsg)
}
})
2、springboot端
package com.example.hello.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 微信小程序数据传送接口
*/
@RestController
@RequestMapping("/text/auth")
public class WxController {
@RequestMapping("/getAllData")
public Map getData( String startTime,String dateEnd){
Map<String, Object> result = new HashMap<>();
result.put("htruck", 250);
return result;
}
}
本文记录了微信小程序通过GET请求与SpringBoot后台进行数据交互的过程,包括微信小程序的JS编写和SpringBoot端的设置,以实现双方联调。
1万+

被折叠的 条评论
为什么被折叠?



