diff --git a/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/ImageController.java b/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/ImageController.java index f559cf80bb..c9e846905a 100644 --- a/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/ImageController.java +++ b/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/ImageController.java @@ -57,7 +57,9 @@ public class ImageController { @RequestMapping(value = "/image-resource", method = RequestMethod.GET) @ResponseBody - public Resource getImageAsResource() { - return new ServletContextResource(servletContext, "/WEB-INF/images/image-example.jpg"); + public ResponseEntity getImageAsResource() { + final HttpHeaders headers = new HttpHeaders(); + Resource resource = new ServletContextResource(servletContext, "/WEB-INF/images/image-example.jpg"); + return new ResponseEntity<>(resource, headers, HttpStatus.OK); } }