Spring security login always lands in an error page with no message

后端 未结 6 1356
夕颜
夕颜 2020-12-16 06:22

I\'m using a login form for a small project in Spring but I have a small problem which is that every time I log in using a sign in form I get an error redirection.

T

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-16 06:44

    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.

提交回复
热议问题