get请求的headers中没有content-type这个字段,get请求的参数在url的?后面,请求参数是Query String Parameters;
Spring MVC使用注解:@RequestParam来接受参数
我们目前常见的post请求的content-type有以下两种
Content-Type: application/x-www-form-urlencoded
Content-Type: application/json
其中 application/x-www-form-urlencoded 可以理解为查询字符串,只不过是放在请求体的body中,不会显示出来,请求参数会在From Data中
Spring MVC使用注解:@RequestParam来接受参数
而Content-Type:application/json,请求的参数会显示在Request Payload中,请求参数的格式是json。
在Spring MVC中使用@requestbody接收
无论是get还是post,我们的请求参数都是可以放在data里的,只不过ajax和axios会判断请求类别,如果是get请求的话,ajax和axios会把data里的值给拼接到url中;
如果是post请求ajax的默认content-type为
Axios请求的默认content-type为Content-Type:application/json
我们都可以通过设置content-type来改变请求数据类型