映射为map时有个可自定义的参数:mapkey privateString getMapKey(Method method) { String mapKey=null;if(Map.class.isAssignableFrom(method.getReturnType())) {finalMapKey mapKeyAnnotation = method.getAnnotation(MapKey.class);if(mapKeyAnnotation !=null) { mapKey=mapKeyAnnotation.value(); } }retur...
ZhuHongQing: 不是吧 你用的几点几的mybatis,resultType=hashmap这样小写还出错么?那我觉得可能操作不在这里,你还是再仔细看看到底是哪出的错吧.另外你说的id做为key,title做为value这是错误的 他们同为column 那么都会是key. value是数据库里存的值. 回复2015-01-15 宋丹丹丹: mapper文件: <select id="se...
@MapKey("id") Map<Integer,Website> getAllCategories(); 答案在http://stackoverflow.com/questions/11913013/return-hashmap-in-mybatis-and-use-it-as-modelattribute-in-spring-mvc有用 回复 mugbya 1.2k62028 发布于 2015-01-14 更新于 2015-01-14 你改成这样试试 resultType="map" 有用1 回...