用户操作
[留言]  [发消息]  [加为好友] 
订阅我的博客
XML聚合    FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
hdy007的公告
<center>Enjoy yourself everyday !<br><br> <!-- Search Google --> <form method="get" action="http://www.google.cn/custom" target="google_window"> <table bgcolor="#000000"> <tr><td nowrap="nowrap" valign="top" align="left" height="32"> <a href="http://www.google.com/"> <img src="http://www.google.com/logos/Logo_25blk.gif" border="0" alt="Google" align="middle"></img></a> <br/> <label for="sbi" style="display: none">输入您的搜索字词</label> <input type="text" name="q" size="21" maxlength="255" value="" id="sbi"></input> </td></tr> <tr><td valign="top" align="left"> <label for="sbb" style="display: none">提交搜索表单</label> <input type="submit" name="sa" value="搜索" id="sbb"></input> <input type="hidden" name="client" value="pub-4875375186491539"></input> <input type="hidden" name="forid" value="1"></input> <input type="hidden" name="channel" value="0061392915"></input> <input type="hidden" name="ie" value="GB2312"></input> <input type="hidden" name="oe" value="GB2312"></input> <input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:1"></input> <input type="hidden" name="hl" value="zh-CN"></input> </td></tr></table> </form> <!-- Search Google --> <script type="text/javascript"><!-- google_ad_client = "pub-4875375186491539"; /* 160x90, 创建于 08-12-12 */ google_ad_slot = "1404787939"; google_ad_width = 160; google_ad_height = 90; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> <br> <script type="text/javascript"><!-- google_ad_client = "pub-4875375186491539"; /* 160x600, 创建于 08-12-12 */ google_ad_slot = "4270110548"; google_ad_width = 160; google_ad_height = 600; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
文章分类
java
J2EE网站经验共享
Java API设计指南
java开源项目:Jdon Framework
Java框架介绍:Quartz从入门到进阶
JSF:初学者进入JavaWeb世界的跳板
Spring AOP中文教程
XML四种解析器原理及性能比较
当前Java软件开发中几种认识误区
改善代码质量--重构
类与类关系的UML图与代码表现
职业生涯
IT程序员35岁之后的三条活路
软件架构师之路
存档

原创  通过spring取properties资源 收藏

步骤:

1、创建properties文件(如:在WEB-INF/core_config/options.properties),里有option.global.sleep.time=1000 

2、在spring配置文件里加如下配置:

<bean id="messageSource"

class="org.springframework.context.support

.ReloadableResourceBundleMessageSource"

scope="singleton">

<property name="basenames">

<set>

<value>WEB-INF/core_config/options</value>

</set>

</property>

</bean>

3、增加ResourceUtil工具类:

import java.util.Locale;

import org.springframework.context.support.ReloadableResourceBundleMessageSource;

import com.leagle.util.SpringBeanUtil;

/**

 * 资源工具

 */

public class ResourceUtil {

public static String getResourceString(String key) {

ReloadableResourceBundleMessageSource messageSource = (ReloadableResourceBundleMessageSource) SpringBeanUtil

.getBean("messageSource");

return messageSource.getMessage(key, null, Locale.getDefault());

}

}

4、取properties里的值:

ResourceUtil.getResourceString("option.global.sleep.time");

发表于 @ 2008年08月21日 21:59:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:Java5 下实现锁无关数据结构 | 新一篇:多核并行计算时代的来临

  • 发表评论
  • 评论内容:
  •  
Copyright © hdy007
Powered by CSDN Blog