如何給webwork的action里的Field設(shè)置初始值
jdev說到"為什么要放在這里,而不是放到系統(tǒng)配置文件中,然后在系統(tǒng)設(shè)置界面中提供設(shè)置",后來我就用spring來注入了?,F(xiàn)在就把值放入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>
????<!--?收發(fā)外部郵箱?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>
????<!--?收發(fā)外部郵箱?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
你這樣換了部署環(huán)境每次都要改
而且也該是
D://tomcat5//webapps//files"
也許很多人都以為這是最好的方式,可是實(shí)際情況不是這樣,我們的uploadfile目錄已經(jīng)有3G的文件,而基本上每天我們都要發(fā)布新的webapp,如果把uploadfile目錄放到webapp的一個(gè)子目錄,每次部署的時(shí)候都要先把uploadfile copy出來然后再部署。所以我們這么做就是把upload目錄放到其他目錄不影響uploadfile目錄里面的文件。關(guān)于我們項(xiàng)目的部署見我的下一篇文章。謝謝大家。如果您有什么更好的方法請(qǐng)您指教。