How to download StringTemplateGroups from WEB-INF directory of a web archive

this question is somewhat related to this question: stack overflow

I want to use a StringTemplate and want to load my templates through a StringTemplateGroup. Until I use the method shown in the corresponding question to get individual files from the WEB-INF folder, but since I read here , it is considered wrong practice to load templates along the way, because the application may be inside the WAR file, and I cannot use StringTemplateGroup because of the path.

Is there any way you would recommend this? Can I get the entire folder as a stream-like object to read a StringTemplateGroup string, or is there a decent (and not so hacky) way already implemented in StringTemplate?

I'm a little new to Java, but I want to learn :) Thank you so much in advance.

+3
source share
1 answer

You can add the paht context property to the arguments of the JVM environment, for example, in the Tomcat container, you add the argument -DcontextPath = [somewhere] to the startup.sh file, and then get the path to the System.getProperty context ("contextPath"). The context path can also be obtained from -Dcatalina.base in Tomcat.

0
source

Source: https://habr.com/ru/post/1760096/


All Articles