<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # EL表達式 EL能夠極大的簡化我們的開發 EL 全名為 Expression Language,它原本是 JSTL 1.0 為方便存取數據所自定義的語言。當時 EL只能在JSTL標簽中使用。到了JSP2.0 之后,EL已經正式納入成為標準規范之一。 ## 語法 EL 語法很簡單,它最大的特點就是使用上很方便。接下來介紹 EL 主要的語法結構 ~~~ ${sessionScope.user.sex} ~~~ 所有 EL 都是以 ${ 為起始、以} 為結尾的。上述 EL范例的意思是:從 Session 的范圍中,取得用戶的性別。假若依照之前的寫法如下: ~~~ User user = (User)session.getAttribute("user"); String sex = user.getSex( ); ~~~ 兩者相比較之下,可以發現 EL 的語法比傳統 JSP更為方便、簡潔。 ### .與 [ ] 運算符 多數情況下使用.,特殊情況使用[ ] ~~~ <%@page import="com.neusoft.mvcapp.dao.Person"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <% Person person = new Person(); person.setName("neusoft"); session.setAttribute("com.neusoft.person", person); %> name:${sessionScope["com.neusoft.person"].name } </body> </html> ~~~ ### EL變量 EL 存取變量數據的方法很簡單,例 如 :${username}。它的意思是取出某一范圍中名稱為 username的變量。因為我們并沒有指定哪一個范圍的 username,所以它的默認值會先從 Page 范圍找,假如找不到,再依序到 Request、Session、Application 范圍。假如途中找到 username,就直接回傳,不再繼續找下去,但是假如全部的范圍都沒有找到時,就回傳null。 ![](https://box.kancloud.cn/4a0f35db60850542f386d6cf171df24c_492x178.png) *** ### 自動類型轉換 el.jsp ~~~ <%@page import="com.neusoft.mvcapp.dao.Person"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <a href="el2.jsp?score=20">To EL2 Page</a> </body> </html> ~~~ el2.jsp ~~~ <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> ${ param.score+30 } <%= request.getParameter("score")+30 %> </body> </html> ~~~ ### EL 隱含對象 ①與范圍有關的隱含對象 applicationScope sessionScope requestScope pageScope 舉一個例子,其他同理 el.jsp ~~~ <%@page import="com.neusoft.mvcapp.dao.Person"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <a href="el2.jsp?score=20">To EL2 Page</a> <% application.setAttribute("app", "appValue"); %> </body> </html> ~~~ el2.jsp ~~~ <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> ${ app }<br> ${ applicationScope.app } </body> </html> ~~~ ②與輸入有關的隱含對象 param ~~~ ${ param.score } <%= request.getParameter("score") %> ~~~ paramValues ~~~ ${ paramValues.score[1] } <%= request.getParameterValues("score")[1] %> ~~~ EL本身沒有遍歷paramValues的能力,JSTL可以,之后講 如果獲取的參數還有無參的get方法,可以一直使用.找到需要的方法,例如: ~~~ ${ requestScope.user.age } ~~~ ③其他的隱含對象 cookie ~~~ ${ cookie.JESESSIONID.name } -- ${ cookie.JESESSIONID.value } ~~~ initParam ~~~ ${ initParam.initName } ~~~ **pageContext** ~~~ ${ pageContext.request.contextPath } ~~~
                  <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>

                              哎呀哎呀视频在线观看