以前以爲在頁面儘量少使用腳本僅僅是爲了規範代碼,提高可維護性,今天發現還有另外一個原因,由於平時使用的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)
所有在使用中特別是在開發中儘量避免在頁面使用腳本,減少不必要的悲劇。