Codice: Seleziona tutto
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import io.swagger.annotations.Api;
@Controller
@Api(tags = "Errors")
@CrossOrigin(allowedHeaders = "*")
public class AppErrorController implements ErrorController {
@RequestMapping("/error")
@ResponseBody
public String handleError(HttpServletRequest request) {
Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
return status.toString();
}
}