我正在使用彈簧。我有一個外部化的屬性文件。我正在加載它如下。如何在會話範圍內保留屬性值?
<context:property-placeholder location="file:///C:/some.properties"/>
現在我該如何保持會話中的屬性作爲鍵值對?
我試着編寫一個擴展了ServletContextListener的偵聽器。
public class Sample implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent event) {
//here i tried to get the values of properties file as below.
InputStream stream = event.getServletContext().getResourceAsStream("C:\\some.properties");
//But here stream is coming as null
}
}
我在這裏丟失了什麼嗎?
謝謝!
感謝您的回覆。是加載外部化的屬性文件後調用contextInitlalized()?謝謝! – user1016403 2012-07-10 11:17:22
不客氣(如果我真的回答了你的問題,那麼你可以upvote /標記答案接受:)) – 2012-07-10 11:18:20