一、EL表达式内置对象:

小峰servlet/jsp(4)EL表达式

二、EL表达式访问4种范围属性:

寻找值的顺序: page-->request-->session-->application;

 

三、EL表达式接收请求参数:

param单个参数;

paramValues:一组参数

 1 <body>
 2 <form action="el2.jsp" method="post">        //接收post方式提交的参数
 3     <input type="text" name="name"/>
 4     <input type="submit" value="提交el2.jsp"/>
 5 </form>
 6 <a href="el2.jsp?age=12">提交el2.jsp</a>     //接收get方式提交的参数
 7 <form action="el2.jsp" method="post">
 8     <input type="checkbox" name="hobby" value="java语言"/>java语言
 9     <input type="checkbox" name="hobby" value="C#语言"/>C#语言
10     <input type="checkbox" name="hobby" value="php语言"/>php语言
11     <input type="submit" value="提交el2.jsp"/>
12 </form>
13 </body>

小峰servlet/jsp(4)EL表达式

el2.jsp页面接收参数:

 1 <body>
 2 <%
 3     request.setCharacterEncoding("utf-8");
 4 %>
 5 <h1>姓名:${param.name }</h1>
 6 <h1>年龄:${param.age }</h1>
 7 <h1>爱好一:${paramValues.hobby[0] }</h1>
 8 <h1>爱好二:${paramValues.hobby[1] }</h1>
 9 <h1>爱好三:${paramValues.hobby[2] }</h1>
10 </body>

 

四、EL表达式对象操作:

 1 <body>
 2 <%
 3     People zhangsan=new People();
 4     zhangsan.setId(1);
 5     zhangsan.setName("张三");
 6     zhangsan.setAge(20);
 7     request.setAttribute("zhangsan",zhangsan);
 8 %>
 9 <h1>编号:${zhangsan.id }</h1>
10 <h1>姓名:${zhangsan.name }</h1>
11 <h1>年龄:${zhangsan.age }</h1>
12 </body>
View Code

相关文章:

  • 2021-05-19
  • 2021-09-25
  • 2021-11-12
  • 2022-03-06
  • 2022-03-08
  • 2022-12-23
  • 2022-12-23
  • 2021-06-02
猜你喜欢
  • 2022-12-23
  • 2021-12-18
  • 2021-11-19
  • 2021-04-07
  • 2022-01-28
  • 2021-11-29
相关资源
相似解决方案