webappがあり、Spring Securityを使用しています。私が午前問題は常にこれです@RequestMapping(value="/login", method=RequestMethod.GET)
代わりの@RequestMapping(value="/login", method=RequestMethod.POST)
にマッピングされますSpring Security.config - ログインページが正常に動作しない
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeRequests()
.antMatchers("/static/**").permitAll()
.antMatchers("/settings/api/**").permitAll()
.antMatchers("/api/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login").permitAll()
.defaultSuccessUrl("/", true);
}
:私はとsecurity.config
の私の春のセキュリティconfigure
機能を持っています。だから私はHTTPリクエストからユーザー名とパスワードを取得しようとしているときはnull
と出てきます。 POST
メソッドにマップするにはどうすればよいですか?
私はformloginと
@RequestMapping(value="/login", method=RequestMethod.POST)
public String login(HttpServletRequest request, HttpServletResponse response) {
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";
}
あなたは私は私はあなたが働く提案するものとは思わないその内側から関数を呼び出しています見ることができるように私はちょうど私のポストのコントローラを追加しました。私はこれに非常に新しいですので、どんな助けも素敵です。お気軽に –
これは私があなたに伝えるように動作します、これをチェックしてください:http://docs.spring.io/spring-security/site/docs/3.2.x/guides/ form.html – Ulises
ありがとうございます。しかし、それは動作していません。おそらく私は別の場所に問題があります。私は一度それを見つけると更新されます。 –