- 同时支持GET/POST两种请求方式
@RequestMapping(value = "/test", method = {RequestMethod.GET,RequestMethod.POST}) @ResponseBody public String test(HttpServletRequest request) { return "ok"; }
- @RequestMapping 注解能够处理 HTTP 请求的方法, 如 GET, PUT, POST, DELETE 以及 PATCH
@RequestMapping(method = RequestMethod.GET) String get() { return "from get"; } @RequestMapping(method = RequestMethod.DELETE) String delete() { return "from delete"; } @RequestMapping(method = RequestMethod.POST) String post() { return "from post"; } @RequestMapping(method = RequestMethod.PUT) String put() { return "from put"; }