Hello, I have an addition of product images in the admin of the online store, the images are saved in the project directory ("/static/productPic/image.png"). When I display this image it is not displayed on the page. The summary is present: <mvc:resources mapping="/static/**" location="/static/" /> View code: <img src="<c:url value="/static/productPic/${product.orgNamePic}"/>" alt="альтернативный текст"> "alternative text" is displayed in the browser, this image path is displayed in the browser: /sombraShop/static/productPic/b9ebb62354b87f5753ca501f90dfa45c.jpg

  • Problem solved, took the first "/" and it all worked - Yurii
  • Please post your decision as an answer and be able to accept it later. - Slava Semushin
  • Thanks for the help) - Yurii

2 answers 2

images are saved in the project directory ("/static/productPic/image.png")

I do not really understand what you mean by "project directory" in this case. As far as I understand, Spring and the specification of sausages is also not aware of what it is and where to look.

 <mvc:resources mapping="/static/**" location="/static/" /> 

As far as I remember, the default location is looking in the classpath. Is your "project directory" in the classpath?

I highly recommend that you read the following article on how the distribution of static content in Spring MVC works: http://www.baeldung.com/spring-mvc-static-resources

Problem solved, took the first "/" and it all worked