From f144e797fb2b4477d8621c451d57004db5117a45 Mon Sep 17 00:00:00 2001 From: IsaiasMorochi Date: Tue, 3 Sep 2019 07:58:43 -0400 Subject: [PATCH] manejo de errores AccesDeniedPage --- src/main/java/com/config/MvcConfig.java | 6 ++++++ src/main/java/com/config/SpringSecurityConfig.java | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/config/MvcConfig.java b/src/main/java/com/config/MvcConfig.java index 57e750b..46e079e 100644 --- a/src/main/java/com/config/MvcConfig.java +++ b/src/main/java/com/config/MvcConfig.java @@ -3,6 +3,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import java.nio.file.Paths; @@ -31,4 +32,9 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/uploads/**") .addResourceLocations(resourcePath); }*/ + + public void addViewControllers(ViewControllerRegistry registry){ + registry.addViewController("/error_403").setViewName("error_403"); + } + } diff --git a/src/main/java/com/config/SpringSecurityConfig.java b/src/main/java/com/config/SpringSecurityConfig.java index e743f58..22a0d54 100644 --- a/src/main/java/com/config/SpringSecurityConfig.java +++ b/src/main/java/com/config/SpringSecurityConfig.java @@ -49,7 +49,9 @@ protected void configure(HttpSecurity http) throws Exception { .formLogin() .loginPage("/login").permitAll() .and() - .logout().permitAll(); + .logout().permitAll() + .and() + .exceptionHandling().accessDeniedPage("/error_403"); }