在AngularJS Web应用程序中,如何显示403 http响应的自定义错误消息/页面。AngularJS为403 http错误代码显示自定义错误消息/页面
我使用Spring的安全,并检查用户是否有一个合适的roles..and如果他没有我不显示任何错误信息的作用,应用程序返回HTTP错误代码403
此刻/在这种情况下页面。并希望执行此操作。我们应该怎么做 ?
春季启动java代码
http.httpBasic()
.and()
.authorizeRequests()
// Permit these resources
.antMatchers("/login", "/4_security/login.html", "/bower_components/**", "/4_security/*.js", "/")
.permitAll()
// URL based Authorization control
.antMatchers("/1_reportingEntities/*.html").hasAnyAuthority(authorities)
// All other requests needs authentication
.anyRequest().authenticated()
// Access denied page (403 error)
.and().exceptionHandling().accessDeniedPage("/0_common/accessDenied.html")
.and()
// CSRF protection
.csrf().csrfTokenRepository(csrfTokenRepository()).and().addFilterAfter(csrfHeaderFilter(), CsrfFilter.class);
谢谢我没有使用ui-router。 – Jay
如果你正在使用角路由,那么你可以使用像$ location.path('/ unauthorized')而不是$ injector.get('$ state')。go('unauthorized'); – Maverick