0
我有country.properties
文件,它具有如下的值:迭代鏈表和地圖與所述屬性文件中值
1=USA
91=India
20=Egypt
358=Finland
33=France
679=Fiji
和,有一個響應的類文件,這是設定從數據庫的響應並將其顯示在JSP
文件。我從數據庫獲得的值是code
或integer
的形式。我需要從數據庫獲得該值,並在設置響應之前,我需要使用getProperty(code)
並將該代碼的字符串表示保存到新列表中,然後將該列表傳遞給setResponse
。對於e.g:這是我從數據庫中獲取的價值:我需要我的JSP頁面上顯示爲
col1 | col2 | col3 |
1 helo done
:
col1 | col2 | col3 |
USA helo done
我下面這個教程,http://www.mkyong.com/java/java-properties-file-examples/。 ,但不能準確理解如何實現相同。
這是我DAOImpl
,我需要iterate
並保存mapped key-value
在一個新的列表,然後傳遞給JSP
頁
public class CountDAOImpl implements IDataDAO {
private Connection conn = null;
private Statement statement = null;
private ResultSet rs = null;
private List<String> country_code = new LinkedList<String>();
//created a new list to put mapped string value instead of code
private List<String> countryMapValue = new LinkedList<String>();
public CountResponse getValue(String query) throws Exception {
CountResponse response = new CountResponse();
try {
conn = DBConnection.getInstance().getCpds().getConnection();
statement = conn.createStatement();
rs = statement.executeQuery(query);
// Extract data from result set
while (rs.next()) {
//Retrieve by column name
String cc = rs.getString("country_code");
country_code.add(cc);
}
//Setting the Response
response.setCountry(country_code);
} catch (Exception e) {
}
return response;
}
任何幫助將是巨大的,因爲我是新來的節目現場。
您能分享一些示例或方法,說明如何迭代鏈接列表並將其放入新鏈接列表中? – AKIWEB