2 回答
TA贡献1865条经验 获得超7个赞
这似乎可行:
@Path("/my/rest/path")
public class V1Controller {
@GetMapping(headers = "ApiVersion=V1")
public String myMethod() {
}
}
== and ==
@Path("/my/rest/path")
public class V2Controller {
@GetMapping(headers = "ApiVersion=V2")
public String myMethod() {
}
}
PS:尚未测试,但已在Spring引导教程中看到。
TA贡献1794条经验 获得超8个赞
确实是:例如
PUT method #1
@RequestMapping(method=RequestMethod.PUT, value="/foo",
headers="returnType=Foo")
public @ResponseBody Foo updateFoo(@RequestBody Foo foo) {
fooService.update(foo);
}
//PUT method #2
@RequestMapping(method=RequestMethod.PUT, value="/foo",
headers="returnType=FooExtra")
public @ResponseBody FooExtra updateFoo(@RequestBody FooExtra fooExtra) {
fooService.update(fooExtra);
}
在这里您可以获得文档: 添加自定义标头
添加回答
举报