Search in sources :

Example 1 with SimpleMappingExceptionResolver

use of org.springframework.web.servlet.handler.SimpleMappingExceptionResolver in project Ganster-CMS by Gangster-trio.

the class ShiroConfig method simpleMappingExceptionResolver.

/**
 * 处理异常跳转页面
 */
@Bean
public SimpleMappingExceptionResolver simpleMappingExceptionResolver() {
    SimpleMappingExceptionResolver simpleMappingExceptionResolver = new SimpleMappingExceptionResolver();
    Properties exceptionMappers = new Properties();
    exceptionMappers.setProperty("org.apache.shiro.authz.UnauthorizedException", "403");
    exceptionMappers.setProperty("org.apache.shiro.authz.UnauthenticatedException", "403");
    simpleMappingExceptionResolver.setExceptionMappings(exceptionMappers);
    return simpleMappingExceptionResolver;
}
Also used : SimpleMappingExceptionResolver(org.springframework.web.servlet.handler.SimpleMappingExceptionResolver) Properties(java.util.Properties) ShiroFilterFactoryBean(org.apache.shiro.spring.web.ShiroFilterFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with SimpleMappingExceptionResolver

use of org.springframework.web.servlet.handler.SimpleMappingExceptionResolver in project Ganster-CMS by Gangster-trio.

the class ShiroConfig method simpleMappingExceptionResolver.

/**
 * 处理异常跳转页面
 */
@Bean
public SimpleMappingExceptionResolver simpleMappingExceptionResolver() {
    SimpleMappingExceptionResolver simpleMappingExceptionResolver = new SimpleMappingExceptionResolver();
    Properties exceptionMappers = new Properties();
    exceptionMappers.setProperty("org.apache.shiro.authz.UnauthorizedException", "403");
    exceptionMappers.setProperty("org.apache.shiro.authz.UnauthenticatedException", "403");
    simpleMappingExceptionResolver.setExceptionMappings(exceptionMappers);
    return simpleMappingExceptionResolver;
}
Also used : SimpleMappingExceptionResolver(org.springframework.web.servlet.handler.SimpleMappingExceptionResolver) Properties(java.util.Properties) ShiroFilterFactoryBean(org.apache.shiro.spring.web.ShiroFilterFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with SimpleMappingExceptionResolver

use of org.springframework.web.servlet.handler.SimpleMappingExceptionResolver in project spring-boot-examples by ityouknow.

the class ShiroConfig method createSimpleMappingExceptionResolver.

@Bean(name = "simpleMappingExceptionResolver")
public SimpleMappingExceptionResolver createSimpleMappingExceptionResolver() {
    SimpleMappingExceptionResolver r = new SimpleMappingExceptionResolver();
    Properties mappings = new Properties();
    // 数据库异常处理
    mappings.setProperty("DatabaseException", "databaseError");
    mappings.setProperty("UnauthorizedException", "403");
    // None by default
    r.setExceptionMappings(mappings);
    // No default
    r.setDefaultErrorView("error");
    // Default is "exception"
    r.setExceptionAttribute("ex");
    // r.setWarnLogCategory("example.MvcLogger");     // No default
    return r;
}
Also used : SimpleMappingExceptionResolver(org.springframework.web.servlet.handler.SimpleMappingExceptionResolver) Properties(java.util.Properties) ShiroFilterFactoryBean(org.apache.shiro.spring.web.ShiroFilterFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 4 with SimpleMappingExceptionResolver

use of org.springframework.web.servlet.handler.SimpleMappingExceptionResolver in project Asqatasun by Asqatasun.

the class ExceptionResolverConfiguration method createSimpleMappingExceptionResolver.

@Bean
public SimpleMappingExceptionResolver createSimpleMappingExceptionResolver() {
    SimpleMappingExceptionResolver resolver = new SimpleMappingExceptionResolver();
    Properties errorMaps = new Properties();
    errorMaps.setProperty("org.asqatasun.webapp.exception.ForbiddenUserException", "access-denied");
    errorMaps.setProperty("org.asqatasun.webapp.exception.ForbiddenPageException", "access-denied");
    errorMaps.setProperty("org.asqatasun.webapp.exception.ForbiddenAuditException", "access-denied");
    errorMaps.setProperty("org.asqatasun.webapp.exception.LostInSpaceException", "oups");
    errorMaps.setProperty("org.asqatasun.webapp.exception.KrashAuditException", "oups");
    errorMaps.setProperty("org.springframework.web.bind.MissingServletRequestParameterException", "access-denied");
    errorMaps.setProperty("org.springframework.web.method.annotation.support.MethodArgumentNotValidException", "access-denied");
    resolver.setExceptionMappings(errorMaps);
    Properties statusCodeMaps = new Properties();
    statusCodeMaps.setProperty("access-denied", "403");
    statusCodeMaps.setProperty("oups", "200");
    resolver.setStatusCodes(statusCodeMaps);
    resolver.setDefaultStatusCode(404);
    return resolver;
}
Also used : SimpleMappingExceptionResolver(org.springframework.web.servlet.handler.SimpleMappingExceptionResolver) Properties(java.util.Properties) Bean(org.springframework.context.annotation.Bean)

Aggregations

Properties (java.util.Properties)4 Bean (org.springframework.context.annotation.Bean)4 SimpleMappingExceptionResolver (org.springframework.web.servlet.handler.SimpleMappingExceptionResolver)4 ShiroFilterFactoryBean (org.apache.shiro.spring.web.ShiroFilterFactoryBean)3