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

View File

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