v4-03 还差一部分,等待完成

78 阅读1分钟

接上篇: V4 -02 SpringSecurity 细致(下篇) bcript加密 md5+盐加密

修改登录成功跳转页面的情况, 修改成返回json串 实现前后端分离

01 登录成功返回json串

---->1.  创建新的类 handler包下 

package com.cy.jt.security.config.handler;

import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class JsonAuthenticationSuccessHandler
        implements AuthenticationSuccessHandler {
    @Override
    public void onAuthenticationSuccess(
            HttpServletRequest httpServletRequest,
            HttpServletResponse httpServletResponse,
            Authentication authentication)
            throw