cometta
cometta

Reputation: 35689

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(){

}

Upvotes: 3

Views: 6371

Answers (2)

Raja Sekhar
Raja Sekhar

Reputation: 1

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.

Upvotes: 0

Jon Skeet
Jon Skeet

Reputation: 1500893

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

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

Upvotes: 24

Related Questions