This is my JAX-RS Put method. I use multiple parameters in here .
@Path("/Add")
public class AddJSONService {
@PUT
@Path("/deactivateAdd/{idAdd}/{activeStatus}")
@Consumes(MediaType.APPLICATION_JSON)
public void deactivateAdd(@PathParam("idAdd") int idAdd, @PathParam("activeStatus") boolean activeStatus) {
AddInterface addInterface = new AddTable();
addInterface.deactivateAdd(idAdd, activeStatus);
}
}
When I run this method, browser brings me following message .
HTTP Status 405 - Method Not Allowed .
Have any ideas about this ?
UPDATED - idAllergy to idAdd.
Unless you are using a custom browser plugin, eg Postman, the browser will always do a HTTP GET when you enter an URL. Your method is specified to accept only PUT requests, and so the request is rejected.
@PathParam
should match the path parameters. idAllergy
-> idAdd
public void deactivateAdd(@PathParam("idAdd") int idSomething, @PathParam("activeStatus") boolean activeStatus)
I think you made a mistake with the idAdd parameter.
Could you try with :
@Path("/Add")
public class AddJSONService {
@PUT
@Path("/deactivateAdd/{idAdd}/{activeStatus}")
@Consumes(MediaType.APPLICATION_JSON)
public void deactivateAdd(@PathParam("idAdd") int idAdd, @PathParam("activeStatus") boolean activeStatus) {
AddInterface addInterface = new AddTable();
addInterface.deactivateAdd(idAdd, activeStatus);
}
}
UPDATED: Why are you using PUT instead POST annotation in the webservice? If I understood well, you are not doing a PUT in the browser, isn't that?
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.