<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # JSP 表達式語言(EL) > 原文: [https://beginnersbook.com/2013/11/jsp-expression-language-el/](https://beginnersbook.com/2013/11/jsp-expression-language-el/) 表達式語言(EL)已在 JSP 2.0 中引入。它的主要目的是簡化從 [bean](https://beginnersbook.com/2013/11/jsp-usebean-setproperty-getproperty-action-tags/) 屬性和[隱式對象](https://beginnersbook.com/2013/11/jsp-implicit-objects/ "Implicit objects")訪問數據的過程。 EL 也包括算術運算符,關系運算符和邏輯運算符。 **EL 語法:** ```html ${expression} ``` 大括號內的任何內容在運行時被評估并被發送到輸出流。 **示例 1:表達式語言評估表達式** 在這個例子中,我們在 EL 的幫助下評估表達式。 ```html <html> <head> <title>Expression language example1</title> </head> <body> ${1<2} ${1+2+3} </body> </html> ``` **輸出:** ![EL-example1](https://img.kancloud.cn/3f/6d/3f6d1684e93ffb1bb2807e55b626b17a_443x186.jpg) **示例 2:使用表達式語言獲取`param`變量的值** 在此示例中,我們提示用戶輸入名稱和卷號。在另一個 JSP 頁面上,我們使用 EL 的`param`變量獲取輸入的詳細信息。 index.jsp ```html <html> <head> <title>Expression language example2</title> </head> <body> <form action="display.jsp"> Student Name: <input type="text" name="stuname" /><br> Student RollNum:<input type="text" name="rollno" /><br> <input type="submit" value="Submit Details!!"/> </form> </body> </html> ``` display.jsp ```html <html> <head> <title>Display Page</title> </head> <body> Student name is ${ param.stuname } <br> Student Roll No is ${ param.rollno } </body> </html> ``` 輸出: ![EL-example2](https://img.kancloud.cn/9a/9c/9a9cf24d61f513401f3154d44be2b123_463x205.jpg) ![Expression-lang-example2](https://img.kancloud.cn/00/7e/007e73cd749eae7558eb338e785306ed_463x205.jpg) **示例 3:從應用對象獲取值。** 在這個例子中,我們使用`application`隱式對象設置了屬性,在顯示頁面上我們使用表達式語言的`applicationScope`獲得了這些屬性。 `index.jsp` ```html <html> <head> <title>EL example3</title> </head> <body> <% application.setAttribute("author", "Chaitanya"); application.setAttribute("Site", "BeginnesBook.com"); %> <a href="display.jsp">Click</a> </body> </html> ``` display.jsp ```html <html> <head> <title>Display Page</title> </head> <body> ${applicationScope.author}<br> ${applicationScope.Site} </body> </html> ``` 輸出: ![Expression-lang-example3](https://img.kancloud.cn/50/40/5040024902c16d7fbfa95a7873d8d42c_463x169.jpg) ![EL-example3](https://img.kancloud.cn/ba/96/ba9628c6e0dd70a73c024ff2695d0184_463x169.jpg) **EL 預定義變量:** 與 JSP 中的隱式對象類似,我們在 EL 中預定義了變量。在上面的例子中我們使用了`param`和`applicationScope`,它們也是這些變量的一部分。 + `pageScope`:它有助于獲取存儲在`page`范圍中的屬性。 + `pageContext`:與 JSP [`PageContext`對象](https://beginnersbook.com/2013/11/jsp-implicit-object-pagecontext-with-examples/)相同。 + `sessionScope`:從[`session`對象](https://beginnersbook.com/2013/11/jsp-implicit-object-session-with-examples/)設置的會話范圍中獲取屬性。 + `requestScope`:用于從請求范圍獲取屬性。由[`request`隱式對象](https://beginnersbook.com/2013/11/jsp-implicit-object-request-with-examples/)設置的屬性。 + `param`:類似于`ServletRequest.getParameter`。參考例 2。 + `applicationScope`:用于獲取[`Applicaton`](https://beginnersbook.com/2013/11/jsp-implicit-object-application-with-examples/)級別屬性。與我們在示例 3 中看到的相同。 + `header`:它有助于將 HTTP 請求標頭作為字符串獲取。 + `headerValues`:用于獲取所有 HTTP 請求頭。 + `initParam`:它鏈接到上下文初始化參數。 + `paramValues`:與`ServletRequest.getParmeterValues`相同。 + `cookie`:它映射到 Cookie 對象。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看