您的位置:首页 > 其它

ssh实现ajax最简单的方法

2017-10-06 00:00 309 查看
如何在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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: