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