scriptlet代碼聲明的東西,el是無法直接解析的。
只有在scriptlet中顯式調用pageContext.setAttribute( key,value ),el的${},才能解析
如下面的代碼
<%@ page pageEncoding="UTF-8"%> <% String str="wasw100"; pageContext.setAttribute("str",str); %> <!DOCTYPE HTML> <html> <body> pageScope中的對象: ${pageScope.str } </body> </html> 瀏覽器顯示: pageScope中的對象: wasw100
如果不調用pageContext.setAttribute("str",str);
瀏覽器顯示:pageScope中的對象:
wasw100將不顯示
--EOF--