首页 > 其他 > 详细

El表达式

时间:2015-11-12 17:27:38      阅读:189      评论:0      收藏:0      [点我收藏+]
一、  ${ }直接取值
<%@ 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>
<%
request.setCharacterEncoding("utf-8");
%>
<h1> 姓名:${param.name }</h1 >
</body>
</html>
 
 
 
二、一组数据paramValues
 
 
<%
request.setCharacterEncoding("utf-8");
%>
<h1> 姓名:${param.name }</h1 >
<h1> 年龄:${param.age }</h1 >
 
 
<h1> 爱好一:${paramValues.hobby[0] }</h1 >
<h1> 爱好二:${paramValues.hobby[1] }</h1 >
<h1> 爱好三:${paramValues.hobby[2] }</h1 >
 
 
 
 
三、对象的操作
 
 
<%
People p1=new People();
p1.setId(1);
p1.setName("zhangsan");
p1.setAge(20);
request.setAttribute("zhangsan",p1 );
%>
 
            <h1 >Id: ${zhangsan.id } </h1 >
            <h1 >Name: ${zhangsan.name } </h1 >
            <h1 >Age: ${zhangsan.age } </h1 >
 
 
四、对集合的操作
 
<%
List all= new LinkedList();
all.add(0,"元素一");
all.add(1,"元素二");
all.add(2,"元素三");
all.add(3,"元素四");
request.setAttribute("all", all);
%>
<h1> 第一个是:${ all[0]}</h1 >
<h1> 第二个是:${ all[1]}</h1 >
<h1> 第三个是:${ all[2]}</h1 >
<h1> 第四个是:${ all[3]}</h1 >
 
 
 
 
五、对操作符的操作
<%
request.setAttribute("num1", 12);
request.setAttribute("num2", 13);
request.setAttribute("num3", 13);
request.setAttribute("num4", 23);
 
 
%>
<h1> num1+num2=${num1+num2 }</ h1>
<h1> num1-num2=${num1-num2 }</ h1>
<h1> num1*num2=${num1*num2 }</ h1>
<h1> num1/num2=${num1/num2 }</ h1>

El表达式

原文:http://www.cnblogs.com/phantomfjh/p/4959500.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!