On the local instance, I have relative paths to the folder with pictures, but I noticed that this folder is not included in war, respectively, images are not displayed in the application running on the server. How to include pictures, add a folder with pictures in war (how?) Or register absolute paths and store pictures somewhere else?

    1 answer 1

    If you are not using frontend in the form of apache / nginx to provide access to static resources, then they should be in the WAR file. At the same time, links to static resources should be specified taking into account the ContextPath .

    Any build system, such as Maven or Gradle , can put files from an external directory into a WAR at the application build stage, but it would be much more logical if they were automatically placed there.

    For example, in Maven, there is a standard directory structure for the application. If your images are in the src/main/webapp/static/images directory, then after the application is deployed, they will be available on the absolute http(s)://<ipaddr:port>/${pageContext.servletContext.contextPath}/static/images or relative /${pageContext.servletContext.contextPath}/static/images link

    In this example, the ContextPath is specified using JSTL . Depending on the framework used and markup, there are ways to do it differently.