本文共 1817 字,大约阅读时间需要 6 分钟。
共同点:本质上都是TCP连接
区别: 由于GET请求是直接把请求参数拼接到url上,浏览器往往会对url长度进行限制,所以会对请求参数的大小有所限制,而POST请求是吧请求参数放到body中,因此大小没有限制
GET请求会被浏览器主动cache,而POST不会,除非手动设置。 由于GET请求的参数会明文显示在url上,post不会,所以Post参数传输更安全 GET产生一个TCP数据包,浏览器会把http header和data一并发送出去;POST产生两个TCP数据包,浏览器先发送header,服务器响应100 continue,浏览器再发送data 对参数的数据类型,GET只接受ASCII字符,而POST没有限制 GET请求只能进行url编码,而POST支持多种编码方式
普通GET:
@GetMapping(value = "optprom/list") JsonResult optionalPromotionList(Term term) throws Exception { return null; }
其请求方式其实是在URL后拼接参数 例如:https://localhost/api/pos/promotion/optprom/list?page=1&rows=10&q=
路径参数 @PathVariable:
@GetMapping(value = "optprom/{id}") JsonResult optionalPromotion(@PathVariable Long id) throws Exception { return null; }
application/json @RequestBody:
@PostMapping(value = "optprom/save") JsonResult optionalPromotionSave(@RequestBody OptionalPromotion optionalPromotion) throws Exception { return null; }
application/x-www-form-urlencoded @RequestParam
@PostMapping(value = "message/wms") public JsonResult wmsmessage(@RequestParam Mapparams) throws Exception{ return null; }
转载地址:http://djnab.baihongyu.com/