2016-03-30 7 views
0

/j_spring_security_check春のセキュリティのためのカスタムログイン処理ページを設定するには?私は、私はいくつかのグーグルを行なったし、春見つけすなわち</p> <pre><code>@RequestMapping(value="/login", method=RequestMethod.POST) </code></pre> <p>クラスで定義されているコントローラからのログインを処理するために、春のセキュリティを取得中に問題を抱えていた

としてデフォルトのログインprocessngページを取りますだから私はどのように私は定義したコントローラからログイン処理を行う春にすることができます。

私はsecurity.configファイルでこれを持って

@Override 
protected void configure(HttpSecurity http) throws Exception { 

    try { 
     http 
     .csrf().disable() 
     .authorizeRequests() 
     .antMatchers("/static/**").permitAll() 
     .antMatchers("/settings/api/**").permitAll() 
     .antMatchers("/api/**").permitAll() 
     .anyRequest().authenticated() 
     .and() 
     .formLogin() 
     .loginPage("/login").permitAll() 

     .defaultSuccessUrl("/", true); 
    } catch (Exception e) { 
     // TODO Auto-generated catch block 
     System.out.println("sadhiasdniaaaaaaaaaaaaaaaa:"); 
     e.printStackTrace(); 
    } 
} 

私は春がログインを処理するために、このコントローラを使用したいが、それは

@RequestMapping(value="/login", method=RequestMethod.POST) 
public String login(HttpServletRequest request, HttpServletResponse response) { 
    System.out.println("\n\n\n*******hello11111111111111********  " + request.getSession().getAttribute("userLoginStatus")); 
    String username = request.getParameter("username"); 
    String password = request.getParameter("password"); 
    boolean f = false; 
    f = customAuthenticationProvider.verifyUser(username,password,request); 
    if(f == false) 
     return "loginError"; 
    else 
     return "index"; 
} 
+0

設定がよさそうです。あなたの問題は何ですか? – Evgeny

+1

なぜですか?あなたは本当にそれを回避しないでSpring Securityと統合するべきです(あなたが今行っていることです)。 –

+0

ええ、ええ、まだ、これを行うには何らかの方法が必要です。私は追加しようとしました\t \t \t .loginProcessingUrl( "/ login") セキュリティ設定ファイルにはまだ幸運はありません –

答えて

0

があなたのコントローラを作成し使用していないcustom authentication provider Spring security.xmlファイルの<認証マネージャー/>の下に接続します。このような構成の例については、hereを参照してください。

関連する問題

 関連する問題