-
GET(查询,参数在URL后拼接)
-
DELETE(删除,参数在URL后拼接)
-
PUT(更新,参数在URL后拼接)
-
POST(保存,参数放入body中,格式使用application/x-www-form-urlencoded)
-
Spring Boot相关注解
//包含在path中提交参数
@RequestMapping(path = "/{id}", method = RequestMethod.GET)
public String getStore(@PathVariable String id) {}
//可代替@RequestMapping(method = RequestMethod.GET)
@GetMapping
//可代替@RequestMapping(method = RequestMethod.POST)
@PostMapping
//可代替@RequestMapping(method = RequestMethod.PUT)
@PutMapping
// 可代替@RequestMapping(method = RequestMethod.DELETE)
@DeleteMapping
//可以设置默认值,比如分页
@RequestParam(value = "name", required = true)
//请求体映射实体类,需要指定http头的content-type为application/json,charset=utf-8
@RequestBody
//请求头,比如鉴权
@RequestHeader("access_token") String accessToken
//使用自动注入获取参数
HttpServletRequest request
网友评论