db_user = postgres
db_password = dbpw
db_location=192.168.1.100
db_name=Test
這樣做的好處是避免IP或密碼變更時,無須動到CODE
<%@page import="java.util.ResourceBundle"%> <% ResourceBundle resource = ResourceBundle.getBundle("config"); String DB_Name = resource.getString("db_name"); String IP = resource.getString("db_location"); String USER = resource.getString("db_user"); String PSW = resource.getString("db_password"); %>
參考來源
http://stackoverflow.com/questions/12686465/how-to-use-property-file-in-jsp
沒有留言:
張貼留言