Monday, 27 January 2020

file upload error Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported]

Problem :

file upload error Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported]



Solution:


If you are using Spring MVC with Spring security then main problem was in spring security.

I resolved this problem by adding ${_csrf.parameterName}=${_csrf.token} 

to end of my form action


HTML:

1
2
3
4
<form method="POST" action="/uploadExcelFile?${_csrf.parameterName}=${_csrf.token}" enctype="multipart/form-data">
 <input type="file" name="file" /><br/><br/>
 <input type="submit" value="Submit" />
</form>

No comments:

Post a Comment

Spring boot with CORS

CORS (Cross-Origin Resource Sharing) errors occur when a web application running in a browser requests a resource from a different domain or...