错误403与错误404

时间:2018-05-08 09:35:33

标签: java spring spring-security

我想确保只有管理员进入/设置页面。

问题在于,当普通会员访问它时,它会显示错误404。

不应该是错误403 ??该页面存在但成员无权输入该页面。

怎么了?

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

    http.authorizeRequests().antMatchers("/settings").hasAuthority("Administrator")
            .anyRequest().authenticated()
            .and()
            .formLogin().permitAll()
                .loginPage("/login").permitAll()
                .defaultSuccessUrl("/dashboard")
                .failureUrl("/login?error")
                .successHandler(authenticationSuccessHandler)
            .and()
            .logout()
                .logoutUrl("/logout")
                .logoutSuccessUrl("/login")
                .logoutSuccessHandler(logoutSuccessHandler)
            .and()
            .exceptionHandling().accessDeniedPage("/errors/error403")
            .and()
                .csrf().disable();
}

0 个答案:

没有答案
相关问题