Answer the question
In order to leave comments, you need to log in
Why is the DELETE request being ignored?
There is a Dynamic Web Project - Java EE7 REST API project on eclipse.
Implemented it with Jersey and Tomcat 8.5 server. Everything works, but it was required to run it easier using mvn exec:java
:(
I downloaded Apache Maven 3.5.2, without thinking I did this:
mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-grizzly2 -DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false -DgroupId=com.wkwn -DartifactId=rest-example-Dpackage=com.wkwn.rest.example -DarchetypeVersion=2.22.2
mvn clean compile
it mvn install
in the created folder rest-example . @DELETE
@Produces(MediaType.APPLICATION_JSON)
public Response deleteNote(Note note) {
if (note.getId() == null)
return MyResponse.badNullId();
else if (NoteArray.removeNoteById(note.getId()))
return MyResponse.goodDelete(note.getId());
else
return MyResponse.badNotFoundId(note.getId());
}
Answer the question
In order to leave comments, you need to log in
server.getServerConfiguration().setAllowPayloadForUndefinedHttpMethods(true);
Oh hey, a DELETE request with a body! Do not do it this way.
@DELETE @Path("{id}")
public Response deleteNote(@PathParam Long id) {
if (NoteArray.removeNoteById(id))
return MyResponse.goodDelete(id);
else
return MyResponse.badNotFoundId(id);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question