http POST请求键值对参数以及json参数

发送键值对参数:

对body里参数进行处理,使其变为键值对形式,下面为angular示例代码

method: RequestMethod.Post,
body: HttpService.buildURLSearchParams(paramMap),
headers: new Headers({
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8;'
})

 

发送json参数:

默认即可,在请求头中声明json

method: RequestMethod.Post,
body: paramMap,
headers: new Headers({
  'Content-Type': 'application/json;charset=utf-8'
})

你可能感兴趣的:(前端)