问题描述
packageliebiao;importdao.DB;importjava.sql.*;importjavax.naming.*;importcom.opensymphony.xwork2.ActionContext;importjava.util.*;publicclassxialaliebiao{privateConnectionconn;privateStatementstate;privateResultSetrs;publicxialaliebiao(){if(conn==null){try{conn=DB.getConnection();}catch(SQLExceptionse){se.printStackTrace();}}}publicHashMapaddressMap(){HashMaphm=newHashMap();try{state=conn.createStatement();rs=state.executeQuery("select*fromaddress");while(rs.next()){hm.put(String.valueOf(rs.getInt("id")),rs.getString("address"));}}catch(SQLExceptione){e.printStackTrace();}finally{try{rs.close();state.close();}catch(SQLExceptione){e.printStackTrace();}}returnhm;}}这是我重数据库得到的map,在吧map的值添加到jsp的下拉列表中怎么弄啊,最好用foreach,高了半天也没弄好求高手知道
时间: 2024-12-29 14:09:10