javaWeb之EL标签简单总结

<%--1.el可以进行自动的类型转化 --%>
score:${param.score +11}<br/>

score:<%=request.getParameter("score")+11 %><br/>

/*
url地址栏http://localhost:8080/ELx/el2.jsp?score=23
输出结果
score:34
 score:2311
*/
 <%--2.EL的[]和.运算符 --%>
	 age:${sessionScope.uu["uid"]}<br/>
	 
	 <%--
	 	上面的啥时用[]比如下面的
	 	如果遇对象的属性名带有".",则用[]会很方便
	 	
	  --%>
	  <%
	 	 UserBean uux = new UserBean();
	 		uux.setUid(89);
	 	session.setAttribute("cn.itcast.bean",uux);
	  %>
	 	
	 	age:${sessionScope["cn.itcast.bean"].uid};
<!-- 3.隐含对象是pageScope,requestScope,sessionScope,applicationScope-->
	time:${time }<br/>
/*
${username}。它的意思是取出某一范围中名称为 username
的变量。因为我们并没有指定哪一个范围的 username,所以它的默认值会先从 Page 范围找,假如
找不到,再依序到 Request、Session、Application 范围。假如途中找到 username,就直接回传,
不再继续找下去,但是假如全部的范围都没有找到时,就回传 null
*/
<!-- 4.param与paramValues -->
	score:${param.score }<br/>
	a:${paramValues.a[0] }<br/>

/*
${param.属性名}:获取一个请求参数
	${paramValues.属性名}:获取一组请求参数(一般用于checkbox)
	
*/
<!-- 5.其他隐含对象 Cookie -->
	JSESSIONID:${cookie.JSESSIONID.name }<br/>
	JSESSIONID:${cookie.JSESSIONID}<br/>
	
	headers:${header["Accept-Language"] }<br/>
	
	<!-- pageContext等() -->
	initParam:${initParam.df }<br/>
	
	contextPath:${pageContext.request.contextPath }<br/>
	localPort:${pageContext.request.localPort }<br/>
	servletPath:${pageContext.request.servletPath }<br/>
	servletContext:${pageContext.request.servletContext }<br/>
	
	<!-- 
		输出结果
        initParam:sdfg
		contextPath:/ELx
		localPort:8080
		servletPath:/el3.jsp
		servletContext:org.apache.catalina.core.ApplicationContextFacade@18600ed
	 -->
	
	
	

 

	<!-- 6.empty可以作用于一个集合 若该集合不存在或几何中没有元素 其结果都为true -->
	
	<%
		List<String> list = new ArrayList<String>();
		list.add("asdf");
		List<String> list1 = new ArrayList<String>();
		request.setAttribute("name", list);
		request.setAttribute("name1", list1);
	%>
	
	the empty:${empty name }<br/>
	the empty:${empty name1 }<br/>
	the empty:${empty name2 }
	
	<!-- 
		输出结果
		the empty:false
		the empty:true
		the empty:true
	 -->

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值