以前以为在页面尽量少使用脚本仅仅是为了规范代码,提高可维护性,今天发现还有另外一个原因,由于平时使用的tomcat,在编译jsp的时候限制比较宽松,所有如下代码可以通过:
<%
List days = new ArrayList();
for(int i=1;i<=30;i++){
days.add(i);
}
request.setAttribute("days",days);
%>
但是如果在websphere下运行就会报错!
the method add(int,object) in the type list is not applicable for the arguments(int)
所有在使用中特别是在开发中尽量避免在页面使用脚本,减少不必要的悲剧。