我有一個servlet,我獲取所有表單值並將其存儲在變量中,在該servlet本身中,我試圖更新我的屬性文件。但屬性文件沒有得到更新。任何人都可以告訴我如何訪問我的表單值並更新我的屬性文件。使用表單值更新屬性文件不起作用
的Servlet文件
protected void doPost
(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException {
// TODO Auto-generated method stub
String name=request.getParameter("appName");
String link=request.getParameter("appLink");
String database=request.getParameter("appDB");
String webServices=request.getParameter("appWebService");
FileInputStream in = new FileInputStream("server_url.properties");
Properties props = new Properties();
props.load(in);
FileOutputStream outputStream = new FileOutputStream("server_url.properties");
props.setProperty("DemoApps_Links", link);
props.setProperty("DemoApps_DataBase", database);
props.store(outputStream , null);
outputStream .close();
System.out.println(link);
System.out.println(database);
}
你在Servlet中正確地獲取參數嗎? – Ved 2015-03-02 12:29:08
在關閉它之前嘗試刷新流:outputStream.flush(); – flayn 2015-03-02 13:06:39