简体   繁体   中英

annotated post and get on same method

may i know is it possible to annotate one method with 2 post and get ?

@RequestMapping(value = "/testonly", 
                method = RequestMethod.GET, RequestMethod.POST)
public String getSomething(){

}

The method field is an array, so I'd expect this to work:

@RequestMapping(value = "/testonly",
                method = { RequestMethod.GET, RequestMethod.POST })

It shouldn't supposed to pass method type as both GET and POST. It will throw unexpected exception if we pass both GET and POST.

Regards, Raja Sekhar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM