Requestmethod POST not supported || Spring login

request method 'post' not supported spring boot
request method 'get' not supported spring boot
o.s.web servlet pagenotfound request method 'post' not supported
request method 'post' not supported postman
request method 'post' not supported spring security
request method 'put' not supported spring boot
org.springframework.web.httprequestmethodnotsupportedexception: request method 'get' not supported
request method 'post' not supported ajax

I got an error, when trying to login on my page when starting maven tomcat on eclipse.

"There was an unexpected error (type=Method Not Allowed, status=405). Request method 'POST' not supported"

I aleady included csrf token in the form. Maybe you can help e solving this.

WebSecurity:

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

@Override
// Authentication : User --> Roles
protected void configure(AuthenticationManagerBuilder auth)
        throws Exception {
    auth.
            inMemoryAuthentication()
            .withUser("user")
            .password("1234")
            .roles("USER")
            .and()
            .withUser("admin")
            .password("5678")
            .roles("USER", "ADMIN");
}

// Authorization : Role -> Access
protected void configure(HttpSecurity http) throws Exception {
    http
            .authorizeRequests()
            .antMatchers("/cont/**").access("hasRole('USER') or 
hasRole('ADMIN')")
            .antMatchers("/admin/**").access("hasRole('ADMIN')")

            .and()
            .formLogin()
                .loginPage("/loginForm.html")                                  
                .defaultSuccessUrl("/login-success", true)                   
                .loginProcessingUrl("/performLogin")
                .failureUrl("/failLogin.html")
                .permitAll()
                .and()
                .logout().permitAll().logoutUrl("/logout")

            .and()
            .csrf()
            .disable()
            .headers()
            .frameOptions()
            .disable();
}

@Autowired
private UserDetailsService userDetailsService;

@Bean
public UserDetailsService userDetailsService() {
    return super.userDetailsService();
}

@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws 
Exception {
    BCryptPasswordEncoder pe = new  BCryptPasswordEncoder();
    auth.userDetailsService(userDetailsService).passwordEncoder(pe);
}

}

Controller

@RequestMapping(value="/performLogin", method= {RequestMethod.GET})
public ModelAndView loginForm() {
    return new ModelAndView("loginForm.html");
}

//Login Success    
@RequestMapping(value = "/login-success", method=RequestMethod.GET)
public ModelAndView loginSuccess() {
    return new ModelAndView("/cont/home.html");
}
}

HTML

<html xmlns:th="http://www.thymeleaf.org">

<head th:include="layout :: head(title=~{::title},links=~{})">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Please Login</title>
<link href="styles/login.css" rel="stylesheet" type="text/css">
</head>

<body th:include="layout :: body" th:with="content=~{::content}">
<div th:fragment="content" id="formLogin">
    <form name="f" th:action="@{/login}" method="POST" autocomplete="off">

            <div id="sign">A</div>

            <article id="formContent">
                <div class="inpt">
                <input type="text" id="username" name="username" 
placeholder="Username"/>
                </div>

                <div class="inpt">
                <input type="password" id="password" name="password" 
placeholder="Password"/>
                </div>
                <input type="hidden" name="${_csrf.parameterName}" 
value="${_csrf.token}"/>

                <div>
                    <button type="submit">Login</button>
                </div>
            </article>
    </form>
</div>
</body>
</html>

Stacktrace:

    2018-10-10 14:03:13.642  INFO 3448 --- [  restartedMain] model.MainApplicationClass               : Starting MainApplicationClass on PGES0074 with PID 3448 (C:\Users\KroemerT\eclipse-workspace\TestOne\target\classes started by kroemert in C:\Users\KroemerT\eclipse-workspace\TestOne)
    2018-10-10 14:03:13.646  INFO 3448 --- [  restartedMain] model.MainApplicationClass               : No active profile set, falling back to default profiles: default
    2018-10-10 14:03:13.760  INFO 3448 --- [  restartedMain] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@674dbea2: startup date [Wed Oct 10 14:03:13 CEST 2018]; root of context hierarchy
    2018-10-10 14:03:15.213  INFO 3448 --- [  restartedMain] o.s.core.annotation.AnnotationUtils      : Failed to introspect annotations on [class org.springframework.boot.actuate.autoconfigure.EndpointWebMvcHypermediaManagementContextConfiguration]: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
    2018-10-10 14:03:15.214  INFO 3448 --- [  restartedMain] o.s.core.annotation.AnnotationUtils      : Failed to introspect annotations on [class org.springframework.boot.actuate.autoconfigure.EndpointWebMvcHypermediaManagementContextConfiguration]: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
    2018-10-10 14:03:17.071  INFO 3448 --- [  restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
    2018-10-10 14:03:17.089  INFO 3448 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service Tomcat
    2018-10-10 14:03:17.091  INFO 3448 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.11
    2018-10-10 14:03:17.442  INFO 3448 --- [ost-startStop-1] org.apache.jasper.servlet.TldScanner     : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
    2018-10-10 14:03:17.447  INFO 3448 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
    2018-10-10 14:03:17.447  INFO 3448 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3692 ms
    2018-10-10 14:03:18.101  INFO 3448 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'metricsFilter' to: [/*]
    2018-10-10 14:03:18.102  INFO 3448 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
    2018-10-10 14:03:18.102  INFO 3448 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
    2018-10-10 14:03:18.102  INFO 3448 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
    2018-10-10 14:03:18.102  INFO 3448 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
    2018-10-10 14:03:18.104  INFO 3448 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
    2018-10-10 14:03:18.104  INFO 3448 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'webRequestLoggingFilter' to: [/*]
    2018-10-10 14:03:18.105  INFO 3448 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'applicationContextIdFilter' to: [/*]
    2018-10-10 14:03:18.105  INFO 3448 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
    2018-10-10 14:03:18.965  INFO 3448 --- [  restartedMain] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/css/**'], Ant [pattern='/js/**'], Ant [pattern='/images/**'], Ant [pattern='/webjars/**'], Ant [pattern='/**/favicon.ico'], Ant [pattern='/error']]], []
    2018-10-10 14:03:19.075  INFO 3448 --- [  restartedMain] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@3b1fae40, org.springframework.security.web.context.SecurityContextPersistenceFilter@14d2b09e, org.springframework.security.web.header.HeaderWriterFilter@67aff8eb, org.springframework.security.web.authentication.logout.LogoutFilter@26763c4, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@38a45f15, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@6f2af3e3, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@4aab9820, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@68d7b4ed, org.springframework.security.web.session.SessionManagementFilter@62ffcb8e, org.springframework.security.web.access.ExceptionTranslationFilter@39fa5fc8, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@7e08d83]
    2018-10-10 14:03:19.094  INFO 3448 --- [  restartedMain] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration$LazyEndpointPathRequestMatcher@38184e5f, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@1eb61155, org.springframework.security.web.context.SecurityContextPersistenceFilter@9eabf8a, org.springframework.security.web.header.HeaderWriterFilter@2a54667a, org.springframework.security.web.authentication.logout.LogoutFilter@276a4420, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@2bc67089, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@112a0e5a, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@18c4ddb3, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@6ec6832, org.springframework.security.web.session.SessionManagementFilter@f55a142, org.springframework.security.web.access.ExceptionTranslationFilter@5ad85015, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@564e18d9]
    2018-10-10 14:03:19.203  INFO 3448 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@674dbea2: startup date [Wed Oct 10 14:03:13 CEST 2018]; root of context hierarchy
    2018-10-10 14:03:19.301  INFO 3448 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/document/all],methods=[GET]}" onto public java.util.List<model.Document> model.DocumentController.getAll()
    2018-10-10 14:03:19.303  INFO 3448 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/document/new],methods=[POST]}" onto public void model.DocumentController.addDocument(model.Document)
    2018-10-10 14:03:19.303  INFO 3448 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/document/remove],methods=[GET]}" onto public void model.DocumentController.removeUser()
    2018-10-10 14:03:19.303  INFO 3448 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/performLogin],methods=[POST]}" onto public org.springframework.web.servlet.ModelAndView model.DocumentController.loginForm()
    2018-10-10 14:03:19.303  INFO 3448 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/login-success],methods=[POST]}" onto public org.springframework.web.servlet.ModelAndView model.DocumentController.loginSuccess()
    2018-10-10 14:03:19.304  INFO 3448 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/logout],methods=[GET]}" onto public org.springframework.web.servlet.view.RedirectView model.DocumentController.logoutPage(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
    2018-10-10 14:03:19.304  INFO 3448 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/loggeduser],methods=[GET]}" onto public java.lang.String model.DocumentController.printUsername(org.springframework.ui.ModelMap,java.security.Principal)
    2018-10-10 14:03:19.304  INFO 3448 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/document/date],methods=[GET]}" onto public java.lang.String model.DocumentController.gDate()
    2018-10-10 14:03:19.308  INFO 3448 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
    2018-10-10 14:03:19.309  INFO 3448 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
    2018-10-10 14:03:19.336  INFO 3448 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Root mapping to handler of type [class org.springframework.web.servlet.mvc.ParameterizableViewController]
    2018-10-10 14:03:19.336  INFO 3448 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/people] onto handler of type [class org.springframework.web.servlet.mvc.ParameterizableViewController]
    2018-10-10 14:03:19.336  INFO 3448 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/home] onto handler of type [class org.springframework.web.servlet.mvc.ParameterizableViewController]
    2018-10-10 14:03:19.356  INFO 3448 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
    2018-10-10 14:03:19.356  INFO 3448 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
    2018-10-10 14:03:19.429  INFO 3448 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
    2018-10-10 14:03:19.920  INFO 3448 --- [  restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/env/{name:.*}],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint.value(java.lang.String)
    2018-10-10 14:03:19.920  INFO 3448 --- [  restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/env || /env.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
    2018-10-10 14:03:19.922  INFO 3448 --- [  restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/beans || /beans.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
    2018-10-10 14:03:19.923  INFO 3448 --- [  restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/health || /health.json],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(java.security.Principal)
    2018-10-10 14:03:19.925  INFO 3448 --- [  restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/metrics/{name:.*}],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint.value(java.lang.String)
    2018-10-10 14:03:19.925  INFO 3448 --- [  restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/metrics || /metrics.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
    2018-10-10 14:03:19.927  INFO 3448 --- [  restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/heapdump || /heapdump.json],methods=[GET],produces=[application/octet-stream]}" onto public void org.springframework.boot.actuate.endpoint.mvc.HeapdumpMvcEndpoint.invoke(boolean,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException,javax.servlet.ServletException
    2018-10-10 14:03:19.928  INFO 3448 --- [  restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/trace || /trace.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
    2018-10-10 14:03:19.929  INFO 3448 --- [  restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/dump || /dump.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
    2018-10-10 14:03:19.934  INFO 3448 --- [  restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/mappings || /mappings.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
    2018-10-10 14:03:19.935  INFO 3448 --- [  restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/configprops || /configprops.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
    2018-10-10 14:03:19.936  INFO 3448 --- [  restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/info || /info.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
    2018-10-10 14:03:19.937  INFO 3448 --- [  restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/autoconfig || /autoconfig.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
    2018-10-10 14:03:20.079  INFO 3448 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
    2018-10-10 14:03:20.187  INFO 3448 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
    2018-10-10 14:03:20.211  INFO 3448 --- [  restartedMain] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
    2018-10-10 14:03:20.417  INFO 3448 --- [  restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
    2018-10-10 14:03:20.424  INFO 3448 --- [  restartedMain] model.MainApplicationClass               : Started MainApplicationClass in 7.348 seconds (JVM running for 7.937)
    2018-10-10 14:06:20.381  INFO 3448 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
    2018-10-10 14:06:20.382  INFO 3448 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
    2018-10-10 14:06:20.401  INFO 3448 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 19 ms
    2018-10-10 14:06:20.469  WARN 3448 --- [nio-8080-exec-1] o.s.web.servlet.PageNotFound             : Request method 'POST' not supported
    2018-10-10 14:06:20.470  WARN 3448 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported
    2018-10-10 14:06:34.683  WARN 3448 --- [nio-8080-exec-7] o.s.web.servlet.PageNotFound             : Request method 'POST' not supported
    2018-10-10 14:06:34.684  WARN 3448 --- [nio-8080-exec-7] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported

I read through many similar question asked here but couldnt find a solution.

I think there is issue in this line in both method

@RequestMapping(value = "/login-success", method = {RequestMethod.POST, 
RequestMethod.GET})

You have configured both GET and POST for a rest call

Try this

 @RequestMapping(value = "/login-success", method=RequestMethod.POST)

In a highly simplified way, MVC HTTP methods are basic operations that a request can trigger on the server. For example, some methods fetch  @RequestMapping(value = "/addStudent", method = RequestMethod.POST) which filters to only allow POST requests to access this method. In order to allow GET requests, change the Mapping for another addStudent method with

I've seen people brainstorm over "the same code that works there but not here" all day long, only to figure out that they did't allow/set up their desired method in CORS settings. That'd be my best guess.

The biggest lesson for you is not to make wild guesses, though, but to utilize tools such as advanced REST client, postman, your browser's dev tools. I.e. you can easily confirm whether CORS filter is an issue if you check the response headers in your browser. To open dev tools in google chrome, press CTRL + SHIFT + J. Your main preoccupation would be the network tab for this particular case, in order to check out whether you have the required headers. POST method requires CORS filters being set up properly by default.

Request method 'POST' not supported” after put security annotations - spring. UPD:I helped add to the login controller RequestMethod.POST getHeader(​TOKEN_STRING); if ((token == null) || (token.length() == 0)) { return ""; } return token; }  There are 2 things flawed in your setup. You should post to /login instead of /j_spring_security_check as that is the new URL when using java config (and in Spring 4 for XML config also). You have set the usernameParameter to name and your form still has username. Fix those flaws

Actually you don't need a post method for login because spring security is managing that. You only need a GET login method. Try to delete your POST login.

Spring How to handle “Request method POST not supported” error for Restful API - spring. exception in Spring MVC, please read following article: Exception Handling in Spring MVC CLIENT_ERROR || statusCode.series() == HttpStatus. Trouble with Login using Spring Boot and JDBC Security. spring,spring-security,spring-boot. There are 2 things flawed in your setup. You should post to /login instead of /j_spring_security_check as that is the new URL when using java config (and in Spring 4 for XML config also). You have set the usernameParameter to name and your form still has

With spring security causing "Request method 'POST' not supported" #1011 not supported at org.springframework.web.servlet.mvc.method. Spring declares all the supported request methods under an enum RequestMethod; it specifies the standard GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE verbs. The Spring DispatcherServlet supports all of them by default except OPTIONS and TRACE; @RequestMapping uses the RequestMethod enum to specifies which methods are supported. 3.

In your code you cannot create a ResponseStatus since it is abstract but I tested java - Using Spring MVC, accepting POST requests with bad JSON leads t. @RequestMapping(value="/ajax/saveVendor.do", method = RequestMethod. add( prefix, v ); } else { buildParams( prefix + "[" + ( typeof v === "object" || jQuery. When I generated my first entity with a one-to-many relationship, when running the app, I got the message "Request method 'POST' not supported" everytime I want to save a new record.

Following might help. While you deploy the application, spring boot displays all the available services on the console. Check the POST method to create is being​  3. Spring @PostMapping Example @PostMapping is specialized version of @RequestMapping annotation that acts as a shortcut for @RequestMapping(method = RequestMethod.POST). @PostMapping annotated methods handle the HTTP POST requests matched with given URI expression. e.g.

Comments
  • login where is the mapping.? In your controller it is /user-login". In your configuration it is performLogin. So where the login request goes?
  • So i should set everyhing to the same path? The loginProcessingUrl, JSP and the mapping?
  • of course......
  • Well, I did but still the same problem. And sorry, I'm pretty new to spring.
  • Clean and Build the project. Please try to include stacktrace in question.
  • Can you add "/login" method. As in your JSP page you are doing POST call with url "/login"
  • What shall this /login method do?
  • You are asking me? This url is responsible for getting username and password and validate. I do see you have added "loginProcessingUrl" may be you need to replace "login" with "performLogin" in JSP
  • And how do i check if these filters are set up?
  • Check out for CorsFilter or some other class that you defined, the one that implements your Filter. If you didn't create it, then you'll need to do it yourself. In fact, this can be done on multiple ways, including xml configuration, so I am not sure about what's convenient for your specifc case and what your spring framework version supports. This link would be much more helpful in order to get a start, pay attention it's spring 4.x: concretepage.com/spring-4/…
  • I changed it to that: .loginPage("/loginForm.html") .defaultSuccessUrl("/login-success", true) .loginProcessingUrl("/performLogin") .failureUrl("/failLogin.html") and: @RequestMapping(value="/performLogin", method= {RequestMethod.GET}) @RequestMapping(value = "/login-success", method=RequestMethod.GET) But still get POST Error
  • .authorizeRequests().antMatchers("/**").permitAll().anyRequest().authenticated().and().csrf().disable().formLogin().loginPage("login").permitAll().loginProcessingUrl("login").usernameParameter("username").passwordParameter("password") .defaultSuccessUrl("/").failureUrl("/error").userDetailsService(userDetailsService) .and() .logout().logoutUrl("/logout").logoutSuccessUrl("/login").permitAll();
  • that's my login my GET @GetMapping("/login") public ModelAndView login(@RequestParam(required = false, name = "error") String error, ModelAndView modelAndView) { modelAndView.setViewName("login"); if(error != null) modelAndView.addObject("error", error); return modelAndView; }
  • What's with that? That shall work?