I have a jsp file where the form is located:

<form:form modelAttribute="user" class="form-horizontal" method="${register ? 'post' : 'put'}" enctype="multipart/form-data" action="${register ? 'register' : 'edit'}" charset="utf-8" accept-charset="UTF-8"> 

i use taglib spring-a

 <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 

The problem is that a request is not sent from this form.

In the book Spring in action it is written that for this it is enough to add the following code:

 FilterRegistration.Dynamic hiddenHttpMethodFilter = servletContext .addFilter("hiddenHttpMethodFilter", new HiddenHttpMethodFilter()); hiddenHttpMethodFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*"); 

This code is in the WebApp class in the onStartup method:

 public class WebApp implements WebApplicationInitializer { private static final String DISPATCHER_SERVLET_NAME = "dispatcher"; private static final String DISPATCHER_SERVLET_MAPPING = "/"; @Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(SpringRootConfig.class); ... 

In the controller there is such a method that should process this request:

 @PutMapping(value = "/edit") public String updateProfile(@Valid User user, BindingResult result) { ... 

What could be the problem??? Although when I send from the same form post request everything works.

  • and what's in the browser console? and what is in the server logs? - Mikhail Vaysman
  • There is an opinion that the put method is not supported in html in principle. Try to put put through javascript (ajax). - Sergey
  • In the browser 405 error: Request method 'POST' not supported - Jacob Burtsev
  • Sergey, I'm struggling with this problem. I know that put cannot be sent from some browsers, but hiddenHttpMethodFilter helps to bypass it. But while I can not. (I want to try without ajax) - Jacob Burtsev

0