When you try to submit a PUT or DELETE HTTP request via form submission, and you want to invoke the methods annotated with @PUT or @DELETE in the Controller to handle the request.
Unfortunately it does not work.
There is a simple solution which can help us to overcome this issue.
If you have used Spring MVC before and I think you could know there is a HiddenMethodFilter in the Spring MVC to fix this issue. Java EE 8 MVC does not ship the similar Filter, we can create one.
Solution
Create a Filter to convert the request method to the target HTTP method.
@PUT @Path("{id}/status")publicResponseupdateStatus(@PathParam(value ="id") Long id, @NotNull @FormParam(value ="status") String status) {log.log(Level.INFO,"updating status of the existed task@id:{0}, status:{1}",newObject[]{id, status});Task task =taskRepository.findById(id);task.setStatus(Task.Status.valueOf(status));taskRepository.update(task);flashMessage.notify(Type.info,"Task status was updated successfully!");returnResponse.ok("redirect:tasks").build(); }