Example usage for org.springframework.web.servlet.handler SimpleMappingExceptionResolver SimpleMappingExceptionResolver

List of usage examples for org.springframework.web.servlet.handler SimpleMappingExceptionResolver SimpleMappingExceptionResolver

Introduction

In this page you can find the example usage for org.springframework.web.servlet.handler SimpleMappingExceptionResolver SimpleMappingExceptionResolver.

Prototype

SimpleMappingExceptionResolver

Source Link

Usage

From source file:org.beast.project.template.config.ExceptionResolverConfig.java

@Bean
public SimpleMappingExceptionResolver simpleMappingExceptionResolver() {
    SimpleMappingExceptionResolver smer = new SimpleMappingExceptionResolver();
    smer.setOrder(2);//from  ww  w. j av  a 2 s  . c  om
    smer.setDefaultErrorView("errorPage");
    Properties props = new Properties();
    props.setProperty("javax.servlet.ServletException", "errorPage404");
    smer.setExceptionMappings(props);
    return smer;
}

From source file:org.socialsignin.showcase.SocialSignInShowcaseWebappConfig.java

@Bean
public HandlerExceptionResolver defaultHandlerExceptionResolver() {
    SimpleMappingExceptionResolver resolver = new SimpleMappingExceptionResolver();
    Properties mappings = new Properties();
    mappings.put("org.socialsignin.springframework.social.security.signin.NonUniqueConnectionException",
            "connect/providerConnect");

    resolver.setDefaultErrorView("exception");

    resolver.setExceptionMappings(mappings);
    return resolver;
}

From source file:com.gailo22.atmosphere.config.WebConfig.java

@Override
public void configureHandlerExceptionResolvers(final List<HandlerExceptionResolver> exceptionResolvers) {
    final SimpleMappingExceptionResolver resolver = new SimpleMappingExceptionResolver();
    resolver.setDefaultErrorView("errors/error");
    exceptionResolvers.add(resolver);/*from ww  w . j av a  2s.  c  om*/
}

From source file:org.bitcoinrt.atmosphere.config.WebConfig.java

@Override
public void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) {
    SimpleMappingExceptionResolver resolver = new SimpleMappingExceptionResolver();
    resolver.setDefaultErrorView("errors/error");
    exceptionResolvers.add(resolver);//  ww  w  .  j av a  2s . c  o m
}

From source file:nl.avans.ivh5a1.proftaak.config.ApplicationContext.java

@Bean
public SimpleMappingExceptionResolver exceptionResolver() {
    SimpleMappingExceptionResolver exceptionResolver = new SimpleMappingExceptionResolver();

    Properties exceptionMappings = new Properties();

    exceptionMappings.put("net.petrikainulainen.exception.TodoNotFoundException", "error/404");
    exceptionMappings.put("java.lang.Exception", "error/error");
    exceptionMappings.put("java.lang.RuntimeException", "error/error");

    exceptionResolver.setExceptionMappings(exceptionMappings);

    Properties statusCodes = new Properties();

    statusCodes.put("error/404", "404");
    statusCodes.put("error/error", "500");

    exceptionResolver.setStatusCodes(statusCodes);

    return exceptionResolver;
}

From source file:org.ameba.http.AbstractMvcConfiguration.java

/**
 * {@inheritDoc}//from ww w  . j  av a  2 s.co m
 *
 * Error page is tried to be resolved at public/error, the exception attribute is set to {@literal exception}.
 */
@Override
public void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) {
    SimpleMappingExceptionResolver smer = new SimpleMappingExceptionResolver();
    smer.setDefaultErrorView("public/error");
    smer.setExceptionAttribute("exception");
    exceptionResolvers.add(smer);
}

From source file:org.socialsignin.showcase.config.SocialSignInShowcaseWebappConfig.java

@Bean
public HandlerExceptionResolver defaultHandlerExceptionResolver() {
    SimpleMappingExceptionResolver resolver = new SimpleMappingExceptionResolver() {

        @Override//from   w  w w  . j ava2s  .c o m
        protected ModelAndView getModelAndView(String viewName, Exception ex, HttpServletRequest request) {
            return addProviderToModelIfAvailable(super.getModelAndView(viewName, ex, request), ex);
        }

        @Override
        protected ModelAndView getModelAndView(String viewName, Exception ex) {
            return addProviderToModelIfAvailable(super.getModelAndView(viewName, ex), ex);
        }

        private ModelAndView addProviderToModelIfAvailable(ModelAndView mav, Exception ex) {
            if (ex instanceof ApiException) {
                mav.addObject("provider", ((ApiException) ex).getProviderId());
            }
            return mav;
        }

    };
    Properties mappings = new Properties();
    mappings.put("org.socialsignin.springframework.social.security.signin.NonUniqueConnectionException",
            "connect/providerConnect");
    mappings.put("org.springframework.social.ExpiredAuthorizationException", "connect/providerConnect");
    mappings.put("org.springframework.social.connect.NotConnectedException", "connect/providerConnect");
    resolver.setDefaultErrorView("exception");

    resolver.setExceptionMappings(mappings);
    return resolver;
}

From source file:ru.portal.config.WebConfig.java

@Bean
public SimpleMappingExceptionResolver simpleMappingExceptionResolver() {
    SimpleMappingExceptionResolver resolver = new SimpleMappingExceptionResolver();
    resolver.setDefaultErrorView("404");
    resolver.setDefaultStatusCode(HttpStatus.NOT_FOUND.value());
    resolver.setOrder(1);//from w w w  .  ja va2 s  .  c om
    return resolver;
}

From source file:aka.pirana.springsecurity.web.config.WebMvcConfig.java

@Bean
public SimpleMappingExceptionResolver simpleMappingExceptionResolver() {
    System.out.println("aka.pirana.springsecurity.web.config.WebMvcConfig.simpleMappingExceptionResolver()");
    SimpleMappingExceptionResolver b = new SimpleMappingExceptionResolver();
    Properties mappings = new Properties();
    mappings.put("org.springframework.dao.DataAccessException", "error");
    b.setExceptionMappings(mappings);/*from   w w  w  . ja v a2 s  .  com*/
    return b;
}

From source file:org.meruvian.yama.webapi.config.JaxrsConfig.java

@Bean
@ConditionalOnMissingBean(SimpleMappingExceptionResolver.class)
public SimpleMappingExceptionResolver resteasyExceptionHandler() {
    SimpleMappingExceptionResolver resolver = new SimpleMappingExceptionResolver();
    resolver.setExceptionMappings(new Properties() {
        {// www  .j a v a  2 s  .  c o m
            setProperty("org.jboss.resteasy.spi.NoResourceFoundFailure", "resteasyNoResourceFoundView");
        }
    });
    resolver.setExceptionAttribute("exception");

    return resolver;
}