读资源文件
来源:互联网 发布:mac的手绘软件 编辑:程序博客网 时间:2024/05/17 07:02
jsp中:<bean:message key="lable.username"/>
方法二:
MessageResources.getMessageResources("com.yourcompany.struts.ApplicationResources");
MESSAGE.getMessage(Locale.CHINESE,"error.username");
注:
getMessageResources()参数为在struts-config.xml中定义的<message-resources parameter="profile.resources.ApplicationResources"/>中的parameter信息。
方法三:
public static final ResourceBundle eBundle =
ResourceBundle.getBundle("config", Locale.SIMPLIFIED_CHINESE);//com.perlong为包名,config为资源文件名
String strMsg = eBundle.getString(strKey);
==========================
非struts下
/**
* 得到资源文件中的一个key的值(1)
*
* @param key 资源文件的key
*
* @return key的对应值
*
* 创建时间:2006年4月17日 8:57
*/
public static String getPropertiesParam(String key){
//资源文件绝对路径
String propertiesFilePath = "E:/workspace/MyClassDepot/src/com/yjg/struts/ApplicationResources_zh.properties";
try{
java.io.InputStream in = new java.io.BufferedInputStream(new java.io.FileInputStream(propertiesFilePath));
java.util.Properties properties = new java.util.Properties();
properties.load(in);
return properties.getProperty(key);
}catch(Exception e){
e.printStackTrace();
}
return null;
}
/**
* 得到资源文件中的一个key的值(2)
*
* @param context context对象
*
* @param key 资源文件的key
*
* @return key的对应值
*
* 创建时间:2006年4月17日 8:57
*/
public static String getPropertiesParam(javax.servlet.jsp.PageContext context,String key){
//资源文件绝对路径 = web根路径 + WEB-INF/classes/com/
String propertiesFilePath = context.getServletContext().getRealPath("/") + "WEB-INF/classes/com/";
try{
java.io.InputStream in = new java.io.BufferedInputStream(new java.io.FileInputStream(propertiesFilePath));
java.util.Properties properties = new java.util.Properties();
properties.load(in);
return properties.getProperty(key);
}catch(Exception e){
e.printStackTrace();
}
return null;
}
- 读资源文件
- Web应用读资源文件
- 资源文件
- 资源文件
- 资源文件
- 资源文件
- 资源文件
- 资源文件
- 资源文件
- 资源文件
- 资源文件
- 资源文件
- 资源文件
- 资源文件
- 资源文件
- 资源文件
- Android 读RAW下的资源文件
- 使用servlet监听器读资源文件
- 1.2 Flex简介
- 1.3 MXML
- tet
- ResourceManager
- makefile简单介绍
- 读资源文件
- 1.4 ActionScript
- ETM 数据分析
- 1.5 Flex的事件机制
- 公布一些常用的WebServices,希望对大家的应用有帮助~
- 1.6 使用Adobe Flex Builder
- code point
- 定时器与多线程 SetTimer and Multi-Thread 每个线程独立使用一个定时器
- 中内容上对齐的属性 valign="top"