tags:

views:

76

answers:

2

Possible Duplicate:
Where are the request method constants in the Servlet API?

I'm looking for a Java string constant to refer to HTTP request methods (GET, POST, PUT, etc.). I expected HttpServlet or HttpServletRequest to have constants for these methods, but that doesn't seem to be the case.

+1  A: 

It seems not: http://stackoverflow.com/questions/1857646/where-are-the-request-method-constants-in-the-servlet-api

Thilo
My searches didn't turn this previous question up. Thanks for posting it.
+2  A: 

In Java Spring, you can use the RequestMapping annotation to isolate different types of request methods. It is in section 13.11.3 of the following link: http://static.springsource.org/spring/docs/2.5.x/reference/mvc.html#mvc-annotation

Essentially you can use these annotations to get the HTTP request method type:

@RequestMapping(method = RequestMethod.GET)
@RequestMapping(method = RequestMethod.POST)
@RequestMapping(method = RequestMethod.PUT)

All the request types are in an enum in the RequestMethod object: http://apollo89.com/java/spring-framework-2.5.3/api/org/springframework/web/bind/annotation/RequestMethod.html

Chris J