You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Windy Hung <wi...@yahoo.com> on 2009/03/25 00:29:52 UTC

getting value from struts.properties in action class

Hi
 I set 
"struts.multipart.saveDir=c:\\test-tmp" in my struts.properties. The setting is for file uploading.
And I would like to check if the directory exists during file loading in my action class.

Is there any easy way to get value out from struts.properties instead of using getClass().getResourceAsStream("struts.properties");

And when is the best time to check if the directory exits? Do I do the checking in Interceptor instead of execute() in action class?

Thanks

Windy Hung


      

Re: getting value from struts.properties in action class

Posted by Rafael Taboada <ka...@gmail.com>.
Try to use ResourceBundle

On Tue, Mar 24, 2009 at 6:29 PM, Windy Hung <wi...@yahoo.com> wrote:

> Hi
>  I set
> "struts.multipart.saveDir=c:\\test-tmp" in my struts.properties. The
> setting is for file uploading.
> And I would like to check if the directory exists during file loading in my
> action class.
>
> Is there any easy way to get value out from struts.properties instead of
> using getClass().getResourceAsStream("struts.properties");
>
> And when is the best time to check if the directory exits? Do I do the
> checking in Interceptor instead of execute() in action class?
>
> Thanks
>
> Windy Hung
>
>
>




-- 
Rafael Taboada
Software Engineer

Cell : +511-992741026

"No creo en el destino pues no me gusta tener la idea de controlar mi vida"

Re: getting value from struts.properties in action class

Posted by Chris Pratt <th...@gmail.com>.
You can use the @Inject annotation to inject values from the struts
properties like this:

import com.opensymphony.xwork2.inject.Inject;

   /**
   * Inject whether XSL Caching should be used
   *
   * @param val The Boolean String Value
   */
  @Inject("struts.xslt.nocache")
  public void setNoCache (String val) {
    noCache = "true".equalsIgnoreCase(val);
  } //setNoCache

(*Chris*)

On Tue, Mar 24, 2009 at 4:29 PM, Windy Hung <wi...@yahoo.com> wrote:

> Hi
>  I set
> "struts.multipart.saveDir=c:\\test-tmp" in my struts.properties. The
> setting is for file uploading.
> And I would like to check if the directory exists during file loading in my
> action class.
>
> Is there any easy way to get value out from struts.properties instead of
> using getClass().getResourceAsStream("struts.properties");
>
> And when is the best time to check if the directory exits? Do I do the
> checking in Interceptor instead of execute() in action class?
>
> Thanks
>
> Windy Hung
>
>
>