Home > Back-end >  Under the spring security to send a post request returns a 405 error
Under the spring security to send a post request returns a 405 error

Time:10-07

The key code:
@ PostMapping ("/login ")
Public String loadUserByUsername (@ RequestBody Logger loggerclient) {
Logger loggerUser=loggerRepository. FindByName (loggerclient getName ());
If (loggerUser==null) {
//throw new UsernameNotFoundException ()
Return "False";
}
Else if (loggerclient. GetPassword (.) the equals (loggerUser. GetPassword ())) {
Return "True";
}
Return "False";
}

Security configuration:
@ Configuration
@ EnableWebSecurity
Public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@ Override
Protected void the configure (HTTP) HttpSecurity throws the Exception {
HTTP. CSRF (). The disable ();
//HTTP. CSRF (.) ignoringAntMatchers ("/login/* * ");
HTTP
AuthorizeRequests ()
AntMatchers ("/", "/register/mail/*", "/login/* *"). The permitAll ()
AnyRequest (). Authenticated ()
And ()
//. CSRF (.) ignoringAntMatchers ("/login/* * ") and ()
FormLogin ()
LoginPage ("/loginPage ")//login page address
PermitAll ()
And ()
The logout ()
PermitAll ();
}
}

CodePudding user response:

Great god see,,, for a long time

CodePudding user response:

May be not closing CSRF set a try

CodePudding user response:

Finally how to solve the
  • Related