Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is exactly server.error.path property?

In Spring Boot, what is the purpose of server.error.path property in application.properties file?

The documentation just says:

Path of the error controller

But I want a clear description of this property with an example.

like image 922
Mahozad Avatar asked Sep 03 '25 15:09

Mahozad


1 Answers

server.error.path - used as part of url for error pages.

site.getBaseUrl() + "/error"

For example some error happen on server side and you decide redirect user to error page like this:

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/images/custom-error-page-aws-404-example.png

Code example of error controller you can find here:

https://www.logicbig.com/tutorials/spring-framework/spring-boot/implementing-error-controller.html

You can use this property in @RequestMapping("/error"). But instead of "/error" you can use "${server.error.path}"

UPDATE:

Also, Spring Boot BasicErrorController use server.error.path property

like image 166
Olesia Ilchuk Avatar answered Sep 05 '25 07:09

Olesia Ilchuk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!