Tomcat will serve any static content from a WAR file using the DefaultServlet.
In this article we will see how we can configure Apache server for serving static content. For example, the URL http://localhost/static/logo.png will send the image ./static/logo. png to the client. The alias directive element allows documents to be stored in the local file system other than under the DocumentRoot.
Tomcat receives a request from a client through one of its connectors. Tomcat maps this request to the appropriate Engine for processing. These Engines are contained within other elements, such as Hosts and Servers, which limit the scope of Tomcat's search for the correct Engine.
Don't put them into WEB-INF, that folder is for the stuff that you do not want to have directly served.
Put it next to WEB-INF
+- WEB-INF
+- static
The files should not be inside WEB-INF. They must be placed directly inside your web-applications directory or WAR file.
Look at my answer here for including the context path before your static resources.
WEB-INF is a protected directory. They must be placed in or in a subdirectory in the top level web app directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With