EL 표현 식 함수 의 간단 한 학습

5656 단어 EL표현 식 함수
<%@page import="java.lang.reflect.Array"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>EL   -       </title>
</head>
<body>
	<h5>EL          </h5>
	
	<%--
		1:fn:contains 
		→	                  
		→   <c:if test="${fn:contains(name, searchString)}">
	 --%>
	 <c:if test="${fn:contains(hanchao,chao) }">
	 	true
	 </c:if>
	 <hr />
	 
	 
	 <%--
	 	2:fn:containsIgnoreCase	
	 	→ 	                (     )
	 	→ 	<c:if test="${fn:containsIgnoreCase(name, searchString)}">
	  --%>
	  <%
	  	request.setAttribute("name", "hanchao");
	    request.setAttribute("searchString", "HAN");
	  %>
	 <c:if test="${fn:contains(name,searchString) }">
	 	true:contains
	 </c:if>
	 <c:if test="${fn:containsIgnoreCase(name,searchString) }">
	 	true:containsIgnoreCase
	 </c:if>
	 <hr />
	 
	 
	 <%--
	 	3:fn:escapeXml	
	 	→	       XML  ,  <      &lt;	
	 	→	${fn:escapeXml(param:info)}
	  --%>
	  <%
	  	//session.setAttribute("beans", "<beans>  </beans>")
	  %>
	  ${fn:escapeXml(beans)}
	  <hr />
	  
	  <%--
	  	4:fn:indexOf	
	  	→	               	
	  	→	${fn:indexOf(name, "-")}
	   --%>
	  <%
	  	pageContext.setAttribute("name", "hanchao is coming");
	    pageContext.setAttribute("in", "in");
	  %>
	  c       :${fn:indexOf(name,"c") }<br />
	  i       【i     】:${fn:indexOf(name,"i") } <br/>
	  co       :${fn:indexOf(name,"co") } <br/> 
	  in       :${fn:indexOf(name,in) }  <hr/>
	 
	  
	  <%--
	  	5:fn:join	
	  	→	                ,         	
	  	→	${fn:join(array, ";")}
	   --%>
	   <%
	   	String[] strs = new String[]{"tom","jerry","alax","hanchao"};
	    pageContext.setAttribute("strs", strs);
	   %>
	   ${fn:join(strs,"----") } <hr/>
	   
	   
	   <%--
	   	6.fn:length	
	   	→	        ,       	[★  、collection  String]
	   	→	${fn:length(shoppingCart.products)}
	    --%>
	    ${fn:length(name) }<br />
	    ${fn:length("hanchao time is coming..") } <hr />
	    
	    
	    <%--
	    	7.fn:replace	
	    	→	           	
	    	→	${fn:replace(text, "-", "&#149;")}
	    --%>
	    ${name }<br />
	    o =  :${fn:replace(name,"o","=") } <hr />
	    
	    
	    <%--
	    	8.fn:split	
	    	→	            	
	    	→	${fn:split(customerNames, ";")} 
	    		       !
	     --%>
	     <%
	     	application.setAttribute("customerNames", "tom,jerry,alax,marry,hanchao,xiaoming");
	     	//★            :items="${fn:split(customerNames,\",\") }"
	     %>
	     <c:forEach items="${fn:split(customerNames,\",\") }" var="item">
	     	${item }
	     </c:forEach>
	     <hr />
	     
	     
	     <%--
	     	9.fn:startsWith	
	     	→	              	
	     	→	<c:if test="${fn:startsWith(product.id, "100-")}">
	      --%>
	      <c:if test="${fn:startsWith(name,\"hanchao\") }">
	      	name   hanchao   
	      </c:if>
	      <hr />
	      
	      <%--
	      	10.fn:substring	
	      	→	    	
	      	→	${fn:substring(zip, 6, -1)}
	       --%>
	       ${name }	<br />
	       ${(fn:substring(name,6,-1)) } <br />
	       ${(fn:substring(name,6,10)) }<hr />
	       
	       
	       <%--
	       	11.fn:substringAfter	
				→	                
			    →	${fn:substringAfter(zip, "-")}
	        --%>
	        ${(fn:substringAfter(name,"is")) }<hr />
	        
	        
	        <%--
	        	12.fn:substringBefore	
	        	→	                 	
	        	→	${fn:substringBefore(zip, "-")}
	         --%>
	         ${fn:substringBefore(name,"is") } <hr />
	         
	         
	         <%--
	         	13.fn:toLowerCase	
	         	→	    	
	         	→	${fn:toLowerCase(product.name)}
	          --%>
	          ${fn:toLowerCase("HANCHAO") }	<hr />
	          
	          
	          <%--
	          	14.fn:toUpperCase	
	          	→	      	
	          	→	${fn:toUpperCase(product.name)}
	           --%>
	           ${fn:toUpperCase(name) } <hr/>
	           
	           
	           
	           <%--
	           	15.fn:trim	
	           	→	          	
	           	→	${fn:trim(name)}
	            --%>
	          ${fn:trim("   blank remove ") }	<hr />
	          
	          
	          <%--
	          	16.fn:endsWith
	          	    →	              	
	     			→	<c:if test="${fn:endsWith(product.id, "100-")}">
	           --%>
	          <c:if test="${fn:endsWith(name, \"ing\")}">
	          	name ing  
	          </c:if>	<hr />
	          
	       	       :
	         http://www.cnblogs.com/zhangliang0115/archive/2012/07/18/2597276.html
	  
</body>
</html>

좋은 웹페이지 즐겨찾기