用postman模拟ajax发送json数据的笔记
header是这个:
但是你后台,你知道吗,用request.getParameter("sysName");是接受不到的,
因为json串在requset的body中。如果不用@RequsetBody
注解,那就要写方法从流中读取参数。
public static String getRequestBody(HttpServletRequest req) throws IOException {
BufferedReader reader = req.getReader();
String input = null;
StringBuffer requestBody = new StringBuffer();
while((input = reader.readLine()) != null) {
requestBody.append(input);
}
return requestBody.toString();
}
参考这位大佬的,牛鼻牛鼻,大佬牛鼻 https://blog.csdn.net/zyjcxc/article/details/79511938