Skip to content

fish-springboot/ErrorHandller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SpringBoot的错误处理

url not found

throw exception

org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration 中定义了bean

如果发生4xx,5xx的错误,就会交给这个Controller处理

	@Bean
	@ConditionalOnMissingBean(value = ErrorController.class, search = SearchStrategy.CURRENT)
	public BasicErrorController basicErrorController(ErrorAttributes errorAttributes) {
		return new BasicErrorController(errorAttributes, this.serverProperties.getError(), this.errorViewResolvers);
	}
@Controller
@RequestMapping("${server.error.path:${error.path:/error}}")
public class BasicErrorController extends AbstractErrorController {
    
}

path = server.error.path != null ? server.error.path : (error.path != null ? error.path : error)

可以通过自己继承ErrorController的方式代替默认的配置

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages