欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

EL(Expression Language)

程序员文章站 2023-08-26 19:42:29
the purpose of el is to aid producing scriptless jsp pages syntax of el in a jsp page:${expr} you...


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.">
   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}