Skip to content
Advertisement

Non-html methods Spring MVC

There is a Spring MVC app. I need to track Put, Patch and Delete form methods. I use java configuration, so there is that file instead of web.xml:

JavaScript

Last method registers HiddenHttpMethodFilter. So where is the problem? There are 2 pages: index.html and show.hmtl. First page is shown when URL is “/files”. Second page is shown when URL is “/files/{id}”. Non-html methods work perfect on the first page, but absolutely don’t work on the second one. Controller:

JavaScript

show.html:

JavaScript

How to add method mapping for multiple URLs?

Advertisement

Answer

I figured out what’s wrong. enctype="multipart/form-data" allows only POST method so HiddenHttpMethodFilter ignored PUT method. To fix it you may remove this form property and change mapping method argument from @RequestParam("file") MultipartFile file to @RequestParam("file") File file

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