java - loading the property file values into web.xml using servletContextListener -


I value my web I want to load XML as a property file

This is my web Xml file

   

And this is my service reference list class

  package com.kpowd.utility; Import java.io.IOException; Import java.util.Properties; Import javax.servlet.ServletContextEvent; Import javax.servlet.ServletContextListener; Public Square PropertyReading ServletContextListener {@Override Public Zero contextDestroyed (ServletContextEvent event) {// TODO Automatic Created Method Stub} @Override Public Zero contextInitialized (ServletContextEvent event) {Final String Theater content = "/config.properties" applies; Last property property file = new property (); Try {propsFromFile.load (getClass (). GetResourceAsStream (props)); } Hold (last IOException e) {e.printStackTrace (); } (String prop: propsFromFile.stringPropertyNames ()) {if (System.getProperty (support) == faucet} {System.setProperty (prop, propsFromFile.getProperty (prop)); }}}}  

When I print the values, this square shows property values ​​to me, but the web In xml when I'm trying to load this value $ {prefethetham}

and this is my config.properties file

  primefacestheme = glass x wellcomepage = accdenied .xhtml  

Please help me

Do you have web You can check with the changes in xml:

  & lt; Context param & gt; & Lt; Ultimate Name & gt; Primefacestheme & lt; / Lastname & gt; & Lt; Ultimate Price & gt; $ {Primefacestheme} & lt; / Super-valued & gt; & Lt; / Reference param & gt; In the form of   

config.properties with the property key name, primefacestheme and in the code we are checking with that key name And if its empty set the property value for that key name

briefly & lt; Param-name & gt; and the property should be the name of the key.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -