EL表达式中的empty运算符和三元运算符

ELDemo1.java文件:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>


<html>
  <head>
    <title>EL运算title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    

  head>

  <body>
    <br/>------empty运算符--------<br/>
    <%
    pageContext.setAttribute("s1", "");
    pageContext.setAttribute("s2", null);
    List list = new ArrayList();
    list.add("aa");
    pageContext.setAttribute("list", list);
    String strs[] = {};
    pageContext.setAttribute("strs", strs);
     %>
    ${empty s1}<br/>
    ${empty s2}<br/>
    ${empty list}<br/>
    ${empty strs}<br/>
    <br/>------三元运算符--------<br/>
    <%
    pageContext.setAttribute("gender", "female");
     %>
     <input type="radio" name="gender" value="male" ${gender=='male'?'checked="checked"':''}/><input type="radio" name="gender" value="female" ${gender=='female'?'checked="checked"':''}/>body>
html>

运行:http://localhost:8080/EL_project/ELDemo1.jsp
结果:
EL表达式中的empty运算符和三元运算符_第1张图片

你可能感兴趣的:(EL表达式)