#39 fix issue /user/image/1 - produces 404 without appropriate HttpResponse message

This commit is contained in:
Art
2021-09-28 10:01:23 +03:00
parent 9210e726bf
commit 6a1a5301b7
2 changed files with 10 additions and 9 deletions

View File

@ -16,6 +16,7 @@ import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.springframework.web.servlet.NoHandlerFoundException;
import javax.persistence.NoResultException;
import java.io.IOException;
@ -83,10 +84,10 @@ public class ExceptionHandling {
return createHttpResponse(METHOD_NOT_ALLOWED, String.format(METHOD_IS_NOT_ALLOWED, supportedMethod));
}
// @ExceptionHandler(NoHandlerFoundException.class)
// public ResponseEntity<HttpResponse> noHandlerFoundException(NoHandlerFoundException exception) {
// return createHttpResponse(BAD_REQUEST, "This page was not found");
// }
@ExceptionHandler(NoHandlerFoundException.class)
public ResponseEntity<HttpResponse> noHandlerFoundException(NoHandlerFoundException exception) {
return createHttpResponse(NOT_FOUND, "Resource not found");
}
@ExceptionHandler(Exception.class)
public ResponseEntity<HttpResponse> internalServerErrorException(Exception exception) {

View File

@ -34,11 +34,11 @@ spring:
max-file-size: 10MB
max-request-size: 100MB
# mvc:
# throw-exception-if-no-handler-found: true
# web:
# resources:
# add-mappings: false
mvc:
throw-exception-if-no-handler-found: true
web:
resources:
add-mappings: false
app:
public-urls: /user/login,/user/register,/user/*/image/**,/user/image/**
cors: