When i access the URL api in the browser, i get this error in the screen:
Request method 'GET' not supported
What i want is to completely remove this error when i access the url directly in the browser. i tried creating a exception handler logic to catch the error and display a blank text but it does not work
here is my code:
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.HttpRequestMethodNotSupportedException;
@controllerAdvice
public class GlobalExceptionHandler{
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public ResponseEntity<String> handleMethodNotAllowedExceptionException(HttpRequestMethodNotSupportedException ex){
return new ResponseEntity<>("",HttpStatus.METHOD_NOT_ALLOWED);
}
}
Is there a way to remove this error from the screen? any help would be appreciated.