Tim Holloway wrote:Actually, the preferred place to put resources in a Maven WAR project is in /src/main/webapp. Using /src/main/resource works, but there is a subtle difference, if I remember.
Also, to locate a webapp resource such as WEB-INF/classes/app.properties, the best way is to use the ApplicationContext getResource() or getResourceAsStream() method, like so:
Tim Holloway wrote:The Resource Path is the location within a WAR relative to the root of the WAR
So if you put a properties file in /WEB-INF/classes/app.properties and try to use /app.properties as its resource path, it will fail.
The Resource Path is the internal resource path, not the external URL resource path
This method is different from java.lang.Class.getResourceAsStream, which uses a class loader. This method allows servlet containers to make a resource available to a servlet from any location, without using a class loader.
The Resource Path is the location within a WAR relative to the root of the WAR
Do you have any official documentation to support this, or an SSCCE? I'm absolutely certain that this statement is wrong.
The path must begin with a / and is interpreted as relative to the current context root, or relative to the /META-INF/resources directory of a JAR file inside the web application's /WEB-INF/lib directory. This method will first search the document root of the web application for the requested resource, before searching any of the JAR files inside /WEB-INF/lib. The order in which the JAR files inside /WEB-INF/lib are searched is undefined.
Where all the women are strong, all the men are good looking and all the tiny ads are above average:
ScroogeXHTML - a fast and small RTF to HTML5 and XHTML converter libraryhttps://coderanch.com/t/742149/ScroogeXHTML-RTF-HTML-XHTML-converter