EL表达式

<%@page import="java.util.Date"%>
<%@page import="web1.Customer"%>
<%@ 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>
	<form action="el1.jsp" method="post">
		username:<input type="text" name="username"
			value="<%=request.getParameter("username") == null ? "" : request.getParameter("username")%>" />

		<br>
		<br>
		<!--回显  -->
		username:<input type="text" name="username" value="${param.username}" />
		<input type="submit" value="Submit" />

	</form>
	username:<%=request.getParameter("username")%>

	<br>
	<jsp:useBean id="customer" class="web1.Customer" scope="session"></jsp:useBean>
	<jsp:setProperty property="id" value="12" name="customer" />

	id:<%
		Customer customer3 = (Customer) session.getAttribute("custoemr");
		out.print(customer3);
	%>
	<br>
	<!-- 换个页面不能输出   -->
	<jsp:getProperty property="id" name="customer" />
	<a href="el2.jsp?score=23&name=A&name=B&name=C">To EL2 Page</a>
	<%
		application.setAttribute("time", new Date());
	%>
</body>
</html>
<%@page import="web1.Customer"%>
<%@ 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>
	<!-- 7.EL运算符   -->
	${param.score>60 ?  "及格":"不及格" }
          name  is empty${empty requestScope.names }
	<!--6 其他隐含对象 pageContext等 (cookie,header,initParam了解)   
       pageContext:pageContext既为pageContext类型  但只能读取属性值就可以一直点下去
       -->
	<br> contextpath: ${pageContext.request.contextPath }
	<br>queryString: ${pageContext.request.queryString }
	<br> sessionid: ${pageContext.session.id }
	<br>
	<br> sessionAttributeNames: ${pageContext.session.attributeNames }
	<br> initParam: ${initParam.initName }
	<br> Accept-Language: ${header["Accept-Language	zh-CN"] }
	<br>


	<!-- 5 于输入有关的隐含对象 param  paramValues -->
	score3:${param.score }
	<br>
	<%=request.getAttribute("scope")%>
	<!-- 不能遍历 有get方法的话可以一直点下去-->
	<br> names:${paramValues.name[0]["class"]}
	<%--=request.getParameterValues("name")[0].getClass().getName() --%>
	<!--4 隐含对象之域范围相关的  pageScope,requestScope,sessionScope,applicationScope  -->
	<br> time:${applicationScope.time }
	<br>
	<%=application.getAttribute("time")%>
	<!--  -->
	<!-- el可以自动类型转换   在el1输出 -->
	score:${param.score+11 } =100 score2:<%=request.getParameter("score") + 11%>
	=8911
	<!-- el中的隐含变量   -->
	<%
		Customer c1 = new Customer();
		c1.setId(49);
		request.setAttribute("customer", c1);
	%>
	<br> id2:${customer.id }
	<!--   session范围内有一个customer  有一个age属性  相当与以下代码 -->
	<br> id:${sessionScope.customer.id }
	<br> id:${sessionScope.customer["id"] }
	<br> id:<%
		Customer customer3 = (Customer) session.getAttribute("custoemr");
		out.print(customer3);
	%>
	<%
		Customer c = new Customer();
		c.setAddress("shanxi");
		session.setAttribute("com.greatest.customer", c);
	%>
	<!-- 如果域对象中的书姓名 带有特殊字符  则使用[]运算符会很方便 -->
	address:${sessionScope["com.greatest.customer"].address}
    

</body>
</html>

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值