If you just need to load a few properties, you shouldn't have to touch
Struts at all. Just create a file, say,
WEB-INF/classes/db.properties, then load it in your Java code via:
Properties props = new Properties();
props.load(this.getClass().getClassLoader().getResourceAsStream("/db.properties");
and away you go...
Don
On 12/13/06, Sébastien LABEY <sebastien.labey@(protected):
> Hi all,
>
> I'd like to load a file containing the parameters to connect to DB at the
> application startup. In the S2 documentation I read about the "key
> initialization parameters" (http://struts.apache.org/2.x/docs/webxml.html)
> and so I add the 2 lines <init-param> to my web.xml like this :
> <filter>
> <filter-name>action2</filter-name>
> <filter-class>
org.apache.struts2.dispatcher.FilterDispatcher> </filter-class>
> <init-param>
> <param-name>config</param-name>
> <param-value>appConfig.xml</param-value>
> </init-param>
> <init-param>
> <param-name>configProviders</param-name>
> <param-value>
> app.core.configuration.ApplicationConfigurationProvider</param-value>
> </init-param>
> </filter>
>
> The appConfig.xml is the file where I have my configuration, it is supposed
> to be at the root (/WEB-INF/), and the
> app.core.configuration.ApplicationConfigurationProvider is the class
> implementing ConfigurationProvider interface as said in the doc.
> In the init() method of the Provider, I just add "System.out.println("--Init
> plugin begin--");" but it never appears in the log, and I cannot see
> anything neither about the xml file nor the Provider.
>
> Maybe, I'm totally wrong and there is a better way to load the file where I
> configure my DB connection?
>
> I'm a little confused, so any help would be appreciated.
>
> Thanks in advance.
>
> Sebastien
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)