• EL表达式简单应用


    <%@page import="java.util.HashMap"%>
    <%@page import="java.util.List"%>
    <%@page import="java.util.ArrayList"%>
    <%@ 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>
    <title>EL表达式</title>
    </head>
    <body>
    <jsp:useBean id="person" class="com.itheima.domain.Person"></jsp:useBean>
    <jsp:setProperty property="name" name="person" value="李四"/>
    <jsp:setProperty property="age" name="person" value="18"/>
    <jsp:setProperty property="sex" name="person" value="男"/>
    <br/>--------------------jsp输出---------------------<br/>
    <%=person.getName()+person.getAge()+person.getSex() %>
    <br/>--------------------EL获取对象的属性---------------------<br/>
    ${person.name }${person.age }${person.sex }
    <br/>--------------------EL获取有序集合的元素---------------------<br/>
    <%
    	List list=new ArrayList();
    	list.add("早上好");
    	list.add("中午好");
    	list.add("晚上好");
    	request.setAttribute("list", list);
    %>
    ${list[0] }${list[1] }
    <br/>--------------------EL获取map集合中的元素---------------------<br/>
    <%
    	HashMap map=new HashMap();
    	map.put("name", "张三");
    	map.put("age","20");
    	request.setAttribute("map", map);
    %>
    姓名:${map.name }年龄:${map.age }
    <br/>------EL小应用----<br/>
    <%request.setAttribute("sex", "0"); %>
    <form action="" method="get">
    	<input type="radio" name="sex" value="1" ${ sex=="1"?"checked='checked'":""}/>男   
    	<input type="radio" name="sex" value="0" ${ sex=="0"?"checked='checked'":""}/>女
    	用到了二元表达式
    </form>
    
    </body>
    </html>
    
  • 相关阅读:
    POJ 2251 Dungeon Master
    HDU 3085 Nightmare Ⅱ
    CodeForces 1060 B Maximum Sum of Digits
    HDU 1166 敌兵布阵(树状数组)
    HDOJ 2050 折线分割平面
    HDU 5879 Cure
    HDU 1878 欧拉回路
    HDU 6225 Little Boxes
    ZOJ 2971 Give Me the Number
    HDU 2680 Choose the best route
  • 原文地址:https://www.cnblogs.com/lzzhuany/p/4716452.html
Copyright © 2020-2023  润新知