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.
Request method 'POST' not supported- Jacob Burtsev