春天如何使用多个@RequestMapping注释? [英] How to use multiple @RequestMapping annotations in spring?
本文介绍了春天如何使用多个@RequestMapping注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在一个方法上使用多个@RequestMapping
注释?
Is it possible to use multiple @RequestMapping
annotations over a method?
赞:
@RequestMapping("/")
@RequestMapping("")
@RequestMapping("/welcome")
public String welcomeHandler(){
return "welcome";
}
推荐答案
@RequestMapping
具有String[]
值参数,因此您应该能够指定多个值,如下所示:
@RequestMapping
has a String[]
value parameter, so you should be able to specify multiple values like this:
@RequestMapping(value={"", "/", "welcome"})
这篇关于春天如何使用多个@RequestMapping注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文