2017-05-17 9 views
-1

SpringセキュリティとAngularJSを使用してdefaultSuccessUrlを設定しようとしていますが、成功したログイン後、htmlページはネットワークに読み込まれますが表示されません。 ここに私のセキュリティ設定defaultSuccessUrlがhtmlページを正しく表示しない

http 
     .authorizeRequests() 
      .anyRequest().authenticated().and() 
     .formLogin() 
      .loginPage("/") 
      .loginProcessingUrl("/") 
      .successHandler(this.authSuccess) 
      .failureHandler(this.authFailure).permitAll() 
      .defaultSuccessUrl("/app/components/hello.jsp", true); 


    http 
     .authorizeRequests() 
      .anyRequest().authenticated().and() 
     .logout() 
      .logoutSuccessHandler(this.logoutSuccess) 
      .deleteCookies("JSESSIONID") 
      .invalidateHttpSession(false).permitAll(); 

ですが、私はネットワークをCHECとき、私は、ログインのためにそのポスト要求は302ステータスコードでリダイレクトされたとHello.jspのはenter image description here

が200のステータスを装填した見ることができますIログインページが表示され、hello.jspページは表示されません。 ログインサービスの角度サービス:

this_.login = function(data) { 
    return $http.post(_contextPath + '/', 
      "username=" + data.username + "&password=" + data.password, { 
       headers : { 
        'Content-Type' : 'application/x-www-form-urlencoded' 
       } 
      }).success(function(response) { 
     return response.status; 
    }).error(function(response) { 
     return response.status; 
    }) 
}; 

なぜですか?

+0

どのようにログインフォームを投稿しますか?アヤックス? – chaoluo

+0

@chaoluo私はフロントエンドでAngularJSを使用しています。私はちょうど投稿要求のためのサービスで私の最初のコメントを更新しました – Med

答えて

0

ログインフォームを投稿するためにajaxを使用しているため、ページは正常なURLにリダイレクトできません。デフォルトのURLを返してから、フロントエンドのURLにリダイレクトできます。 like this

関連する問題