Spring security login always lands in an error page with no message
You can add the always-use-default-target
param to the success URL.
.defaultSuccessUrl("/home",true)
This means that if the login is successful you will always be sent to /home
.
I think the undesirable behaviour is caused by the error page being queued for some reason, and then when the login is successful you get "returned" to that.
This isn't the ideal solution but providing you don't want to go to the previous page after logging in, then it works to prevent your described behaviour.
Maybe this is about that, there is no RequestMapping
with Param
error. Possible solution
@RequestMapping(value={"/", "/login"}, method = RequestMethod.GET)
public ModelAndView login(@RequestParam(value = "error", required = false)){
ModelAndView modelAndView = new ModelAndView();
if (error != null) {
modelAndView.setViewName("error page");
} else modelAndView.setViewName("login");
return modelAndView;
}
Edit1
Might be also caused by not having all following folders in your project "/static/**", "/js/**", "/css/**", "/img/**", "/json/**"
, delete this configure or add all folders.