spring jdbc 如何返回一个map类型结果集

Spring中如何返回一个map<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

/**

* 根据用户id和部门的id来查询一条记录

* @param userid

* @param deptid

* @return

*/

public Map<String,String> load(String userid,String deptid) ;

@SuppressWarnings("unchecked")

public Map<String,String> load(String userid, String deptid) {

String sql = " select * from qxgl_user_dept where user_id=? and dept_id=? ";

return super.getJdbcTemplate().queryForMap(sql,

new Object[] { userid, deptid });

}

==========使用=====================

Map map = deptServiceDao.loadDeptUser(userid, deptid);

if (map == null) {

addActionMessage("未找到符合条件的记录!");

} else {

// userid =(String) map.get("user_id");

// deptid = (String)map.get("dept_id");

log.debug("editDeptUser--根据部门id和用户id找到记录!");

isFirst = ((Integer) map.get("is_first")).intValue();

isLeader = ((Integer) map.get("is_leader")).intValue();

headship = (String) map.get("headship");

userFlag = (String) map.get("user_flag");

remark = (String) map.get("remark");

}

你可能感兴趣的:(spring,sql,jdbc,Microsoft,Office)