環境復現
??????? 前臺:
wx.request({url: 'xxxxxx',method: 'POST',header: {"content-type": "application/json"},success(res) {console.log(res);},fail(err) {console.error('網絡請求失敗', err);}});
??????? 后端使用springboot:
@RequestMapping(value = "/errApiList")
public String getProductionPlanList(HttpServletRequest req, HttpServletResponse res) {String materialCode = req.getParameter("MaterialCode");
}
將請求方式換成GET,后端可以正常拿到數據,但是換成POST就拿不到。
解決方式:
更改請求頭:"content-type": "application/x-www-form-urlencoded"