1. 后台POST的返回HttpHeaders里面设置了HttpHeaders.LOCATION
headers.add(HttpHeaders.LOCATION, "localhost:12345/common");
2.POST
@RequestMapping(value = { "/{subject:[a-zA-Z\\-_]+}/", "/{subject:[a-zA-Z\\-_]+}"}, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Void> create(@PathVariable String subject, @RequestBody String entityString) { System.out.println("create"); HttpHeaders headers = new HttpHeaders(); headers.add("DATE", new Date().toString()); headers.add("URL", "localhost:12345/common"); headers.add(HttpHeaders.LOCATION, "localhost:12345/common"); return new ResponseEntity<>(headers, HttpStatus.CREATED); }
3.GET
@RequestMapping(value = { "/{subject:[a-zA-Z\\-_]+}", "/{subject:[a-zA-Z\\-_]+}/", "/{subject:[a-zA-Z\\-_]+}/search" }, // method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<String> search(@PathVariable String subject, @RequestParam Map<String, String> allRequestParams) { System.out.println("Search"); return new ResponseEntity<>("TEST Search", HttpStatus.OK); }
4.测试结果
5.postman的结果就是正常的
收到!我们对请求201接口会进行重定向,这个问题会在新版本优化好,很快上线,感谢您的反馈
邀请您加入技术交流群,使用过程中有任何问题可以随时在群内与我反馈,我将第一时间协助您解决