Skip to content
Advertisement

HTTP Status 405 – Request method ‘POST’ not supported (Spring MVC)

Im getting this error: HTTP Status 405 - Request method 'POST' not supported

What I am trying to do is make a form with a drop down box that get populated based on the other value selected in another drop down box. For example when I select a name in the customerName box the onChange function in the .jsp page should be run and the page submitted then loaded again with the corresponding values in the customerCountry box.

however I’m getting this HTTP Status 405 error. I have searched the internet for a solution but haven’t been able to find anything that helped. Here is the relevant parts of my code:

part of jsp page

JavaScript

part of controller:

JavaScript

How come I get this error? Any help would be much appreciated! Thanks

EDIT: Changed hasId to hasCustomerName. I still get the HTTP Status 405 - Request method 'POST' not supported error though.

EDIT2: Commented out the line in the setFalse function that was causing the error

// D

Advertisement

Answer

I found the problem that was causing the HTTP error.

In the setFalse() function that is triggered by the Save button my code was trying to submit the form that contained the button.

JavaScript

when I remove the document.submitForm.submit(); it works:

JavaScript

@Roger Lindsjö Thank you for spotting my error where I wasn’t passing on the right parameter!

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement