小程序wxml页面button 按钮
<view> <button bindtap="change">点击</button> //change 为js函数名 </view> 小程序js页面函数 Page({ change: function(event){ wx.request({ url: ‘http://localhost:80/services/login/username‘, //get请求地址 data: { //可携带参数 }, header: { ‘content-type‘: ‘application/json‘ // 默认值 }, success: function(res) { console.log(res.data) //res.data 为接口返回值 }, }) } }) springboot后端接口: @RestController @RequestMapping("/login") public class loginController { @RequestMapping(value = "/username",method = RequestMethod.GET) public String login(HttpServletRequest request){ System.out.println(request.getParameter("userName")); return "请求成功"; } }