在Tomcat环境下修改了.Properties配置文件后,再读取值时得到的是旧值,一定要重启Tomcat才可以得到新值,Help!!! 这个问题在Resin下是不存在的,但在Tomcat下却会变成这样,请问如何才可以解决??急!!!!!在线等!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是我自己定的.properties文件.同样的程序,在Resin下是从来没有这种问题的,但这次必须要把程序移到Tomcat下,竟然出现这种问题.==================================【读取资源文件--------->】 private void init() { p = new Properties(); try { InputStream is = PropertiesInfo.class.getResourceAsStream(propertiesFile); p.load(is); is.close(); }catch(Exception e) { e.printStackTrace(); } }【读key值--------->】 public String getKeyValue(String key) { init(); String keyValue; if(key == "" || key.equals("")) { keyValue = "null"; }else { keyValue = p.getProperty(key, "null"); } p.clear(); return keyValue; }【修改key值-------->】 public boolean setKeyValue(String key, String value) { init(); boolean = true; try { p.setProperty(key, value); java.net.URL url = PropertiesInfo.class.getResource(""); System.out.println(url.getPath()); FileOutputStream fos = new FileOutputStream(url.getPath() + propertiesFile); p.store(fos, ""); fos.close(); p.clear(); }catch(IOException e) { = false; e.printStackTrace(); } return ; } new PropertiesInfo().setKeyValue("key1", "hahahaha");new PropertiesInfo().getKeyValue("key1"); 谢谢我爱花猫!!这样就可以了.Tomcat和Resin的机制到底是有些差别,加载对象的过程不太一样. 在线等待Hibernate高手解决此问题!!!! 谁对spring security比较熟,怎么配置role是‘and’,而不是‘or’ 豆丁文档浏览器技术实现 求教一個STRUTS標簽的簡單問題 提问;如何把一个String型的数据转换成Int型 广结英雄好汉! 初接触ASP,没有基础。十天左右学习上手?请高手支招,谢谢! 请帮我调试一下(很小的) class java.lang.Integer 中未找到方法 getIntValue()。怎么回事呀?)在线等待( 程序无法编译,帮忙找错,谢谢! 数据插入有问题 jsp文件中有action=""調用自己,這個網頁中的變量還會保存嗎?
==================================
【读取资源文件--------->】
private void init() {
p = new Properties();
try {
InputStream is = PropertiesInfo.class.getResourceAsStream(propertiesFile);
p.load(is);
is.close();
}catch(Exception e) {
e.printStackTrace();
}
}
【读key值--------->】
public String getKeyValue(String key) {
init();
String keyValue;
if(key == "" || key.equals("")) {
keyValue = "null";
}else {
keyValue = p.getProperty(key, "null");
}
p.clear();
return keyValue;
}
【修改key值-------->】
public boolean setKeyValue(String key, String value) {
init();
boolean = true;
try {
p.setProperty(key, value);
java.net.URL url = PropertiesInfo.class.getResource("");
System.out.println(url.getPath());
FileOutputStream fos = new FileOutputStream(url.getPath() + propertiesFile);
p.store(fos, "");
fos.close();
p.clear();
}catch(IOException e) {
= false;
e.printStackTrace();
}
return ;
}
new PropertiesInfo().getKeyValue("key1");
Tomcat和Resin的机制到底是有些差别,加载对象的过程不太一样.