程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> JSP編程 >> 關於JSP >> EL(Expression Language)

EL(Expression Language)

編輯:關於JSP


The purpose of EL is to aid producing scriptless JSP pages

Syntax of EL in a JSP page:${expr}
You can escape the expression:
\${expr}

<body>
   <form action="el2.jsp">
   username:<input type="text" name="username">
   password:<input type="submit" name="password">
   <input type="submit" value="submit" >
   </form>

<body>
  ${param.username }
  ${param.password}
  <!--   <%= request.getParameter("username") %>-->
  </body>

Beans within the namespace avaiable to the JSP can be accessed easily using EL.

Beans can be accessed by way of dot notation:${bean.attribute}

Beans can be located by searching through the scopes:page,request,session and application

Beans scope can be specified  by preceding the bean name with the scope
${sessionScope.cust.fristName}

 <%session.setAttribute("aa","bb"); %>

${sessionScope.aa}<br>
  <%=session.getAttribute("aa") %>

Implicit Object :Description

if the bean return an array ,and element can specify its
index using[] nation:
${paramValues.fruit[2]}

username: <input type="text" name="username">
<input type="text" name="username">
<input type="text" name="username">

${paramValue.username[2]}

Example operation
${2+1*3}
User user = new User;
session.setAttribute("user",user);

 

${sessionScope.user.sex}
User user = (User)session.getAttribute("user");
String sex = user.getSex();

${sessionScope.user.sex}equals${sessionScope.user["sex"]}

TypeCast:${param.count+20}

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved