0

我有一个使用 Spring 和 React/Redux 的应用程序。身份验证由WebSecurityConfigwhich extends完成WebSecurityConfigurerAdapter。配置方法:

 @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.csrf()
                .formLogin()
                    .loginPage("/login")
                    .successHandler(new CustomSuccessAuthenticationHandler())

CustomSuccessAuthenticationHandler 如下所示:

CustomSuccessAuthenticationHandlerextends SimpleUrlAuthenticationSuccessHandler implements AuthenticationSuccessHandler{
@Override
    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
        throws IOException, ServletException {
        response.getWriter().write(JsonHelper.objectToJson(new CustomDto()));
    }
}

问题是,在浏览器中,响应没有任何正文。我可以使用它设置 HTTP 状态或标头HttpServletResponse,但如果我写正文 - 它始终为空。我试过使用response.getOutputStream().write(),冲洗等,但没有任何效果。即使我用需要的数据重定向到端点,body 也总是空的。它与前面完成的 React 路由有关吗?

4

0 回答 0