HTTP Status 405 - Request method 'POST' not supported in Spring MVC with Spring Security

I am not sure if this helps but I had the same problem.

You are using springSecurityFilterChain with CSRF protection. That means you have to send a token when you send a form via POST request. Try to add the next input to your form:

<input type="hidden"
name="${_csrf.parameterName}"
value="${_csrf.token}"/>

As far as I saw, the mentioned solutions didn't work for latest SpringSecurity. Instead of passing through with hidden you can also send it through the action URL like below:

<form method="post" action="doUpload?${_csrf.parameterName}=${_csrf.token}" enctype="multipart/form-data">