我是靠谱客的博主 兴奋小懒猪,这篇文章主要介绍SpringSecurity-1-AuthenticationFailureHandler接口(登录失败之后的处理逻辑),现在分享给大家,希望可以做个参考。

@EnableWebSecurity
public class A extends WebSecurityConfigrerAdapter{
		@Override
		protected void configure(HttpSecurity http) throws Exception{
				http.anthorizeRequests().anyRequest().authenticated().and()
				//我不太明白这个processingUrl是什么意思,难道表单中的action可以不写??
				formLogin().loginPage("你的登录页面.html").loginProcessingUrl("/login").
				//以下处理自定义逻辑
				failureHandler(new AuthenticationFailureHandler(){
						@Override
						public void onAuthenticationFailure(HttpServletRequest request,HttpServletResponse,AuthenticationException e){
								//这里直接写自己的处理逻辑,比如下面这段代码
								response.setContentType("application/json;charset=UTF-8");
								PrintWriter out=response.getWriter();
								out.write("一个JSON串");
						}
				})
		}
}

最后

以上就是兴奋小懒猪最近收集整理的关于SpringSecurity-1-AuthenticationFailureHandler接口(登录失败之后的处理逻辑)的全部内容,更多相关SpringSecurity-1-AuthenticationFailureHandler接口(登录失败之后内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(151)

评论列表共有 0 条评论

立即
投稿
返回
顶部