1
I am trying to make a method to delete an entry from a table with Java and jsp
, but is giving error 405. I will attach the codes.
Productodao.java.:
public void remove(Produto produto) {
em.getTransaction().begin();
em.remove(busca(produto));
em.getTransaction().commit();
}
public Produto busca(Produto produto) {
return em.find(Produto.class, produto.getId());
}
Productocontroller.java:
@Delete
public void remove(Produto produto){
dao.remove(produto);
result.redirectTo(this).lista();
}
jsp list.:
<div class="row">
<form action="<c:url value='/produto/remove'/>" method="DELETE">
<div class="col s4">
REMOVER PELO ID:<input type="text" />
</div>
<div class="col s4 right">
<input type="submit" class="btn waves-effect waves-light btn-large right" value="REMOVER"></input>
</div>
</form>
</div>
And the error that appears is this:
HTTP Status [405] - [Method Not Allowed]
Type Status Report
Description The method Received in the request-line is known by the origin server but not supported by the target Resource.
The path is the standard of the convention, but I found the error, it was just a difference of reading from the browser in question to the delete method
– Leonardo Bugoni