二、List的c out。如果你的实体继承了List,而添加了一些属性,想要在页面直接输出这些属性,你可能这样做:
<c:out value="${mylist.myproperty}"/>但是你会发现这是个错误:
javax.servlet.ServletException: The operator was supplied with an index value of type to be applied to a List or array, but that value cannot be converted to an integer.
原因是这样的,当表达式的实体是一个List或者数组数型的话,"."操作符后面跟的属性一律被看作是List或数组的下标了。JSTL试图把它们转成整型,失败就会报错。
不但Out标签存在这个特点,其他也一样。所以在设计实体的时候,如果需要用到List的功能,最好加一个List的成员变量。不需要直接继承。