标签:
1. dao层方法使用泛型
public <T> List<T> findDistinctListByCondition(String str, Class<T> fieldClass) { String sql = "select distinct " + str + " from checkin_request"; List<T> list = (List<T>) jdbcTemplate.query(sql, new RowMapper<Object>(){ @Override public T mapRow(ResultSet rs, int rowNum) throws SQLException { return (T)rs.getObject(1); } }); return list; }
2. action调用
List<Integer> mediatypeList = checkInRequestService.findDistinctListByCondition("mediatype", Integer.class); List<String> currentStatusList = checkInRequestService.findDistinctListByCondition("current_status", String.class);
标签:
原文地址:http://www.cnblogs.com/rocky-fang/p/5660920.html