如何在SSH框架中使用ajax?需要的工作以下所示:
1. 在Struts配置文件中不写result。即不需要给action配置结果集
2. 方法的返回值为void
3. ServletActionContext.getResponse().getWriter().write("this is ajax"); //以这种方式传值
如何给properties配置文件读写?关键是获取到路径
读:
InputStream in = PropertiesHelper.class.getClassLoader().getResourceAsStream("setting.properties");
properties.load(in);
public static String getProperty(String key)
{
if(properties != null && properties.containsKey(key))
return properties.getProperty(key);
return "";
}
写:
String classPath = PropertiesHelper.class.getClassLoader().getResource("/").toURI().getPath();
//OutputStream fos = new FileOutputStream(PropertiesHelper.class.getClassLoader().getResource("/")+"setting.properties");
OutputStream fos = new FileOutputStream(classPath+"setting.properties");
properties.put(key, value);
properties.store(fos, key+"setValue:"+value);