前面一篇文章提到通过webwork的interceptor给webwork的action设置初始值,
upload.directory = D:\\tomcat5\\webapps\\files
mail.attachementDirectory = D:\\tomcat5\\webapps\\files
上次还有网友这样说到"return ServletActionContext.getServletContext().getRealPath("/");
你这样换了部署环境每次都要改
而且也该是
D://tomcat5//webapps//files"
也许很多人都以为这是最好的方式,可是实际情况不是这样,我们的uploadfile目录已经有3G的文件,而基本上每天我们都要发布新的webapp,如果把uploadfile目录放到webapp的一个子目录,每次部署的时候都要先把uploadfile copy出来然后再部署。所以我们这么做就是把upload目录放到其他目录不影响uploadfile目录里面的文件。关于我们项目的部署见我的下一篇文章。谢谢大家。如果您有什么更好的方法请您指教。
如何给webwork的action里的Field设置初始值
jdev说到"为什么要放在这里,而不是放到系统配置文件中,然后在系统设置界面中提供设置",后来我就用spring来注入了。现在就把值放入properties文件中了。
<
bean
id
="propertyPlaceholderConfigurer"
class
="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
>
< property name ="locations" >
< list >
< value > classpath:mail.properties </ value >
< value > classpath:upload.properties </ value >
</ list >
</ property >
</ bean >
<!-- 收发外部邮箱 author:somebody -->
< bean id ="outMailManager" class ="cn.com.fivefortunes.mail.manager.impl.OutMailManagerImpl" >
< property name ="javaMailSender" >< ref bean ="javaMailSender" /></ property >
< property name ="attachementDirectory" >< value > ${mail.attachementDirectory} </ value ></ property >
< property name ="uploadFileDirectory" >< value > ${upload.directory} </ value ></ property >
< property name ="outMailHibernateManager" >< ref bean ="outMailHibernateManager" /></ property >
< property name ="outMailAccountManager" >< ref bean ="outMailAccountManager" /></ property >
</ bean >
这样把uploadFileDirectory放入mananger中去了。在properties里面配置一下就ok了。
< property name ="locations" >
< list >
< value > classpath:mail.properties </ value >
< value > classpath:upload.properties </ value >
</ list >
</ property >
</ bean >
<!-- 收发外部邮箱 author:somebody -->
< bean id ="outMailManager" class ="cn.com.fivefortunes.mail.manager.impl.OutMailManagerImpl" >
< property name ="javaMailSender" >< ref bean ="javaMailSender" /></ property >
< property name ="attachementDirectory" >< value > ${mail.attachementDirectory} </ value ></ property >
< property name ="uploadFileDirectory" >< value > ${upload.directory} </ value ></ property >
< property name ="outMailHibernateManager" >< ref bean ="outMailHibernateManager" /></ property >
< property name ="outMailAccountManager" >< ref bean ="outMailAccountManager" /></ property >
</ bean >
upload.directory = D:\\tomcat5\\webapps\\files
mail.attachementDirectory = D:\\tomcat5\\webapps\\files
你这样换了部署环境每次都要改
而且也该是
D://tomcat5//webapps//files"
也许很多人都以为这是最好的方式,可是实际情况不是这样,我们的uploadfile目录已经有3G的文件,而基本上每天我们都要发布新的webapp,如果把uploadfile目录放到webapp的一个子目录,每次部署的时候都要先把uploadfile copy出来然后再部署。所以我们这么做就是把upload目录放到其他目录不影响uploadfile目录里面的文件。关于我们项目的部署见我的下一篇文章。谢谢大家。如果您有什么更好的方法请您指教。