Java Code Examples for org.springframework.web.servlet.handler.SimpleMappingExceptionResolver#setDefaultErrorView()

The following examples show how to use org.springframework.web.servlet.handler.SimpleMappingExceptionResolver#setDefaultErrorView() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShiroConfig.java    From Spring-Boot-Book with Apache License 2.0 5 votes vote down vote up
@Bean(name = "simpleMappingExceptionResolver")
public SimpleMappingExceptionResolver
createSimpleMappingExceptionResolver() {
    SimpleMappingExceptionResolver r = new SimpleMappingExceptionResolver();
    Properties mappings = new Properties();
    mappings.setProperty("DatabaseException", "databaseError");//数据库异常处理
    mappings.setProperty("UnauthorizedException", "403");
    r.setExceptionMappings(mappings);
    r.setDefaultErrorView("error");
    r.setExceptionAttribute("ex");     // 缺省值"exception"
    return r;
}
 
Example 2
Source File: ShiroConfig.java    From spring-boot-demo with MIT License 5 votes vote down vote up
/**
 * 异常处理
 *
 * @return
 */
@Bean(name = "simpleMappingExceptionResolver")
public SimpleMappingExceptionResolver createSimpleMappingExceptionResolver() {
    SimpleMappingExceptionResolver r = new SimpleMappingExceptionResolver();

    Properties mappings = new Properties();
    mappings.setProperty("DatabaseException", "databaseError");
    mappings.setProperty("UnauthorizedException", "403");
    r.setExceptionMappings(mappings);

    r.setDefaultErrorView("error");
    r.setExceptionAttribute("ex");
    return r;
}
 
Example 3
Source File: ShiroConfig.java    From springBoot-study with Apache License 2.0 5 votes vote down vote up
@Bean(name="simpleMappingExceptionResolver")
public SimpleMappingExceptionResolver
createSimpleMappingExceptionResolver() {
	SimpleMappingExceptionResolver r = new SimpleMappingExceptionResolver();
	Properties mappings = new Properties();
	mappings.setProperty("DatabaseException", "databaseError");//数据库异常处理
	mappings.setProperty("UnauthorizedException","403");
	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;
}