I have following method in my rest service:
@POST
@Path("/create")
@ResponseStatus(HttpStatus.CREATED)
@Consumes(MediaType.WILDCARD)
public String create( .... ) {.... return json;}
so I want to get a response with json in body and status code CREATED.
The problem is: I can’t get a response the CREATED status.
The status code is allways OK, so it seems that “@ResponseStatus(HttpStatus.CREATED)” is just ignored…
Can somebody help me with it?
I’m using hibernate 4.1, spring 3.1 and resteasy 2.3
As far as I know, it’s not possible to achieve this by annotating the method with
@org.springframework.web.bind.annotation.ResponseStatus.You can return
javax.ws.rs.core.Responsefrom your method:Or you can have
org.jboss.resteasy.spi.HttpResponseinjected, and set the status code directly.There might be more ways of doing this, but I’m only aware of these two.
Working testcase: