這裏是我的登錄表單如何j_spring_security_check獲取密碼值
<form class="login-form" action="j_spring_security_check" method="post" >
<fieldset>
<legend>Login Here</legend>
<div class="form-group required">
<label id="inputEmail" class="control-label col-md-4">Email</label>
<div class="col-md-8">
<input type="email" class="form-control" id="username" name="username" placeholder="Enter email" >
</div>
</div>
<div class="form-group">
<label id="inputpwd" class="control-label col-md-4">Password</label>
<div class="col-md-8">
<input type="password" class="form-control" id="pwd" name="password" placeholder="Enter password" >
</div>
</div>
<p><input type="submit" value="Login"/></p>
</fieldset>
</form>
我如何可以檢索輸入,我們給的密碼,它實現的UserDetailsService
public class LoginUserDetails implements UserDetailsService {
@Override
public UserDetails loadUserByUsername(final String username) throws UsernameNotFoundException {
final User user = DataLayer.queryToGetUserDetails(username);
返回新的UserDetails(A類中){
private static final long serialVersionUID = 2059202961588104658L;
@Override
public boolean isEnabled() {
return true;
}
@Override
public boolean isCredentialsNonExpired() {
return true;
}
@Override
public boolean isAccountNonLocked() {
return true;
}
@Override
public boolean isAccountNonExpired() {
return true;
}
@Override
public String getUsername() {
return user.getUsername();
}
@Override
public String getPassword() {
return user.getPassword();
}
//To DO for authentication.
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
List<SimpleGrantedAuthority> auths = new java.util.ArrayList<SimpleGrantedAuthority>();
auths.add(new SimpleGrantedAuthority("patient"));
return auths;
}
};
}
}
我返回上面的值。因此,爲了做定製驗證我需要密碼字段類中提前
哪裏我需要添加此代碼...只是檢查我的代碼粘貼IHAVE我整個userLoginDetails代碼 – Prakhash
<形式登錄登錄頁=「/登錄」 認證失敗-URL =「/錯誤」 用戶名參數=「用戶名「password-parameter =」password「 default-target-url =」/ medicheck「/> I有這樣的security-config.xml。除了這個 –
Prakhash