PUT : 405 - Method not allowed with Spring MVC
PUT : 405 - Method not allowed with Spring MVC
PIGAYE
Posts: 11Questions: 2Answers: 0
Hi,
Every time I try to make update like this :
edit: {
type: 'PUT',
contentType: 'application/json',
url: 'personnephysique/editRow?id=_id_',
data: function (d) {
var newdata;
$.each(d.data, function (key, value) {
newdata = JSON.stringify(value);
});
return newdata;
}
}
I have this error :
"NetworkError: 405 Méthode Non Autorisée - http://localhost:8081/lasieec/personnephysique/editRow?id=29"
However I have this method in my Controller :
/**/
@RequestMapping(value = serviceId + "/editRow", method = RequestMethod.PUT)
public @ResponseBody PersonnePhysiqueEntite putPersonnePhysiqueData( PersonnePhysiqueEntite personnetoPut ) {
personnetoPut = service.savePersonnePhysiqueEntite(personnetoPut);
return personnetoPut;
}
/**/
I really nead you help.
Thank you in advance
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I would start by looking at the server logs to see why its responding with 405 Method Not Allowed.
Look at this:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405
Maybe the server is not allowing
put
. Try changing topost
.Kevin
PUT or POST, the result is same.
I don't why but with firebug I have this response :
Looks like you need to enable POST and or PUT on your Apache web server. According to the above only GET is supported.
Kevin
Thanks you Kevin for your response.
The problem is not caused by Apach server because I use in the same Controller POST and PUT in many other places with simple Html button.
But it is about using DataTables.Editor itself.
I wonder if there is a concret exemple of using Editor with Spring MVC?
If I understand correctly firebug is a web browser tool for troubleshooting. I would still recommend looking at the server log to see why it is responding with 405.
Can you post your full Datatables and Editor config?
What does
newdata
contain?I'm not familiar with Spring MVC nor examples. Maybe someone else can help.
Kevin
Hello Kevin, thank you very much for your great concern.
As you request, I copy the entire code.
We are going to continue digging maybe we will find a solution.
For my part I will inform you as soon as I find a solution.
Thank you for everything.
Here is the code:
This isn't a client-side issue (unless its using the wrong HTTP verb or the work URL). The problem is with the routing on the server-side or some other way it is processing the URL. It is throwing an error - perhaps in a security context, perhaps being it is an unexpected request. But either way, the issue likes in the server's configuration rather than the Javascript you are using.
Allan
I have exactly the same issue. When I used DataTables without the Editor POST worked fine. After adding the Editor plugin I started getting "Failed to load resource: the server responded with a status of 405 (METHOD NOT ALLOWED)" for some reason. I am working with Python/Flask and use development server, which has the least number of security restrictions
I fixed the issue. There was a problem on the back-end
Thanks for posting back. GOod to hear it is working now.
Allan
@lsukharn , Can you point out how you fixed it. I'm also facing the same problem
You would need to look at your server's logs to determine why its responding with a 405 Method Not Allowed error.
Kevin