【Head First Servlets and JSP】筆記21:EL以及<jsp:useBean ....>的補充

來源:互聯網
上載者:User

標籤:map   --   sch   point   org   http   語言   use   image   

1、EL的英文是Expression Language,譯成中文就是“運算式語言”。這是一種給前端程式員使用的指令碼語言,EL與Java運算式相比並沒有什麼“天壤之別”,在後端程式員看來多少有點“多此一舉”。

2、然而,我們不能強求每一個前端程式員都去學習JAVA,EL相對於JAVA來說學習成本更低,更容易理解。

 

3、在以前寫的代碼上實踐測試一下,首先把Scriptlet給禁了,(El也是可以禁的)

<?xml version="1.0" encoding="UTF-8"?><web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"         version="3.1">    <jsp-config>        <jsp-property-group>            <url-pattern>*.jsp</url-pattern>            <scripting-invalid>true</scripting-invalid>        </jsp-property-group>    </jsp-config>    <servlet>        <servlet-name>hi</servlet-name>        <servlet-class>Sample.AddFriends</servlet-class>    </servlet>    <servlet-mapping>        <servlet-name>hi</servlet-name>        <url-pattern>/HobbyPage.do</url-pattern>    </servlet-mapping></web-app>

 這個時候再去訪問含有Scriptlet的JSP頁面,

 

4、本質上來說,EL和Scriptlet是類似的,最後都要轉換為.java-->.class

 

 

5、。。。

 <jsp:useBean ....>既可以用來建立對象,也可以用來取得對象。

 

 

6、<jsp:useBean ....>可以有體

 

7、總之,歸根結底最後都轉化為servlet。

 

推薦閱讀

1、JSP中的Scriptlet -- 經典 書上沒解釋什麼是Scriptlet

2 、Syntax in JSP 

 

【Head First Servlets and JSP】筆記21:EL以及<jsp:useBean ....>的補充

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.