Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.3k views
in Technique[技术] by (71.8m points)

springboot 怎么在 controller 上注解让不同的 url 支持不同的 method?

比如 url1 需要只支持 POST url2 只支持 GET 两个 url 映射到一个方法上,有什么好的方式,如果使用 RequestMapping 分别写两个 url 和 method,会产生四种组合感觉不是太好

老项目做 restful 改造,兼容老的,照顾新的确实很麻烦


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

又见面了

@GetMapping("url1")
@PostMapping("url2")
public void method(){
}

满足需求吗


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...