私のjsf 2.2プロジェクトのプロパティファイルから読みたいです。私は日食ケプラーを使用しています。
パッケージde.exanpleを使用して、フォルダーsrcのjava-beanでこれを使用しようとしています。Bean のファイルは PageServiceBean.java と呼ばれます。
プロパティファイルはWEB-INF/resources/prop
フォルダにあります。プロパティ ファイルは config.properties と呼ばれます。
web.xmlファイルのjsf 2.2のリソースフォルダーを、javax.faces.WEBAPP_RESOUCRES_DIRECTORY
param名とparam値を次のように変更できることを読みました/WEB_INF/resoucres
しかし、設定ファイルへのパスがわかりません。パス名を取得できる場所を教えてください。相対パス名を使用する必要があると思います。手伝ってくれませんか?
アップデート
あなたの好きな 2 番目のコード フラグメントを実行します。
private Properties getProperties() {
Properties prop = new Properties();
try {
//load a properties file
prop.load(new FileInputStream("config2.properties"));
} catch(Exception e) {
}
return prop;
}
public void setProperty1(Integer value) {
Properties prop = getProperties();
prop.setProperty("ort", value.toString());
try {
prop.store(new FileOutputStream("config2.properties"), null);
Properties prop2 = getProperties();
} catch (IOException ex) {
Logger.getLogger(PageServiceBean.class.getName()).log(Level.SEVERE, null, ex);
}
}
できます!を使用しProperties prop3 = getProperties();
て、プロパティ ファイル config2.properties を読み取ります。ファイルはEclipseホームパスに保存されますECLIPSE_HOME = C:\elipse_jee\eclipse
。のような特定のパスにパスを変更できますWEB_INF/resources
か?