2
我遇到了未被Spring Security調用的Primefaces CommandButton操作的問題。沒有Spring安全性就沒問題。 我不明白爲什麼。你可以幫我嗎?CommandButton操作未被Spring Security調用
我使用Primefaces 5.2。和Spring Security 4.0.2。
我有一個託管bean
@Getter
@Setter
@ManagedBean
@ViewScoped
public class LoginController implements Serializable {
private static final long serialVersionUID = 1L;
private String userName = "admin";
private String password = "123";
public void doLogin() {
System.out.println("test");
}
}
而且隨着
<p:commandButton value="Войти в систему" action="#{loginController.doLogin()}" />
我的春季安全配置
@Configuration
@EnableWebSecurity
public class SpringSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
http
.authorizeRequests()
.antMatchers("/javax.faces.resource/**").permitAll()
.antMatchers("/**").access("hasRole('ROLE_USER') or hasRole('ROLE_ADMIN')")
.antMatchers("/admin/**").access("hasRole('ROLE_ADMIN')")
.and()
.formLogin()
.loginPage("/pages/security/login.xhtml")
.permitAll()
.and()
.logout()
.logoutSuccessUrl("/pages/security/login.xhtml?logout")
.permitAll();
}
}
您是否找到任何解決方案?如果是這樣,請分享作爲答案。 – tylerdurden