Jsp的表达式语言(el)

来源:互联网 发布:java双向关联的源代码 编辑:程序博客网 时间:2024/04/30 00:43

推荐网址:

http://www.oracle.com/technology/global/cn/sample_code/tutorials/jsp20/simpleel.html

http://www.ibm.com/developerworks/cn/java/j-jstl0211/

 实例:

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 
1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
--%>

<!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>JSP Page</title>
    
</head>
    
<body>
<%@ include file="test.jsp" %> 
    
<h1>JSP Page</h1>
    
<%
        pageContext.setAttribute(
"color","#FFFFCC");
    
%>
    
<body bgcolor = '${pageScope.color}' >
        
<h1>变化的背景色</h1>
        
<h1>比较运算符</h1>
        
<b>
            
4 &gt; 3 ${4 > 3}<br/>
            
4 &lt; 3 ${4 < 3}<br/>
            
4 &ge; 3 ${4 >= 3}<br/>
            
4 &le; 3 ${4 le 3} <br/>
            
4 = 4 ${4 == 4}
        
</b>
            
<h1>Empty 运算符</h1>
            $
{empty(Null)}
            $
{empty("test")}
        
<b>

        
</b>

    
<%--
    This example uses JSTL, uncomment the taglib directive above.
    To test, display the page like 
this: index.jsp?sayHello=true&name=Murphy
    
--%>
    
<%--
    
<c:if test="${param.sayHello}">
        
<!-- Let's welcome the user ${param.name} -->
        Hello ${param.name}!
    
</c:if>
    
--%>
    
    
</body>
</html>

 

结果:

test

JSP Page

变化的背景色

比较运算符

4 > 3 true
4 < 3 false
4 ≥ 3 true
4 ≤ 3 false
4 = 4 true

Empty 运算符

true false

原创粉丝点击