I have a properties file in /WEB-INF . And I want to load it into a JSF managed bean. Is there any way to do this?
/WEB-INF
Use ExternalContext#getResource() or ExternalContext#getResourceAsStream() in which you pass the relative webcontent path.
ExternalContext#getResource()
ExternalContext#getResourceAsStream()
eg:.
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); Properties properties = new Properties(); // ... properties.load(externalContext.getResourceAsStream("/WEB-INF/file.properties"));
This delegates under the covers of ServletContext#getResource() / getResourceAsStream() .
ServletContext#getResource()
getResourceAsStream()
Put it in WEB-INF / classes. This is part of the class path.
String path="/WEB-INF/list.properties"; InputStream is=FacesContext.getCurrentInstance().getExternalContext().getResourceAsStream(path); InputStreamReader r = new InputStreamReader(is); BufferedReader br = new BufferedReader(r);
Source: https://habr.com/ru/post/1299426/More articles:How to convert Delphi TPageControl tab index to page index? - delphimysql never releases memory - mysqlGet the internal width of the window and the height of the android embedded in the web browser at all zoom levels - androidWhy does WCF need DTC for transaction flow? - .netPe editing library? - c ++Problem with iPhone control panel icon - iphoneLimiting text fields in Java - javaPerformance Problem with Incremental Graph Design - c ++What is wrong with this statement? - mysqlhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1299431/specified-key-was-too-long-max-key-length-is-1000-bytes&usg=ALkJrhieIPof-eTZkZgi4jkYCFehYlghyQAll Articles