Skip to content

Instantly share code, notes, and snippets.

@eruvanos
Created July 15, 2016 20:01
Show Gist options
  • Save eruvanos/5b425edd5950285f2123ea3f737ad58a to your computer and use it in GitHub Desktop.
Save eruvanos/5b425edd5950285f2123ea3f737ad58a to your computer and use it in GitHub Desktop.
Global errorhandler for Spring
package de.siemering.spring.controllers;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.web.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("${error.path:/error}")
public class GlobalErrorController implements ErrorController {
@Value("${error.path:/error}")
private String errorPath;
@Override
public String getErrorPath() {
return this.errorPath;
}
@RequestMapping
public String error() {
return "index";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment