Java tutorial
package com.crown.passthrough; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver; /* * Copyright 2012-2015 Crown Equipment Corporation. All rights reserved. * See license distributed with this file. */ /** * @author jgebhart (Sogeti USA LLC) * @author Sogeti * * @version 1.0, created Oct 9, 2015 * @since 1.0.0 */ @Configuration @EnableWebMvc @ComponentScan(basePackages = { "com.crown.passthrough" }) public class WebConfig extends WebMvcConfigurerAdapter { /** * Spring configuration file. */ @Bean public SimpleMappingExceptionResolver simpleMappingExceptionResolver() { SimpleMappingExceptionResolver r = new CustomSimpleMappingExceptionResolver(); // Properties mappings = new Properties(); // mappings.setProperty("DatabaseException", "databaseError"); // mappings.setProperty("InvalidCreditCardException", "creditCardError"); // r.setExceptionMappings(mappings); // None by default // r.setDefaultErrorView("error"); // No default // r.setExceptionAttribute("ex"); // Default is "exception" // r.setWarnLogCategory("example.MvcLogger"); // No default return r; } }