Annotated post and get the same method

Can I find out if it is possible to annotate one method using 2 messages and receive?

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

}
+3
source share
2 answers

A field methodis an array, so I expect this to work:

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

You should not pass the type of the method to either GET or POST. This will throw an unexpected exception if we pass both GET and POST.

Regards, Raja Sehar.

0
source

Source: https://habr.com/ru/post/1793357/


All Articles