TreeMap的一个错误 ...cannot be cast to java.lang.Comparable
今天在页面使用jstl的<c:froEach>遍历HashMap
<c:forEach items="${ydMap }" var="m"><div /></a>:</div><div var="l"><span /></a></span></c:forEach></div></div></c:forEach>
Map<BaseState,List<BlackChannelStates>> map=new TreeMap<BaseState,List<BlackChannelStates>>();
public class BaseState implements Comparable<BaseState>{private Integer id;public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}}
public TreeMap(Comparator<? super K> comparator) { this.comparator = comparator; }
public class BaseState implements Comparable<BaseState>{private Integer id;public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}@Overridepublic int compareTo(BaseState o) {// TODO Auto-generated method stubreturn o.getId()-this.getId();}}