el表达式(一)

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="cn.sasa.domain.*" %>
    <%@ page import="java.util.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
    <% 
        request.setAttribute("name", "hi");
        
        MyUser user1 = new MyUser();
        user1.setName("aaa");
        session.setAttribute("user", user1);
        
        MyUser user2 = new MyUser();
        user2.setName("bbb");
        List<MyUser> userList = new ArrayList<MyUser>();
        userList.add(user1);
        userList.add(user2);
        application.setAttribute("users", userList);
    %>
    <!-- el表达式从域中取值取值 -->
    <br/>
    ${ requestScope.name }
    <br/>
    ${sessionScope.user.name }
    <br/>
    ${applicationScope.users[0].name }
    ${applicationScope.users[1].name }
    
    <hr/>
    <!-- *全域查找 -->
    <br/>
    ${ name }
    <br/>
    ${user.name }
    <br/>
    ${users[0].name }
    ${users[1].name }
</body>
</html>

 

posted @ 2019-03-29 17:23  SasaL  Views(178)  Comments(0Edit  收藏  举报