EL简用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37334150/article/details/85216327

概述:

                EL表达式用于JSP文件中,从四个作用域中自动获取与之相匹配的变量值。也可以指定:如sessionScope.xxx

                形如:${变量名},例子(含判断变量是否为空的empty运算符实例)如下:

<%@ 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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String info = "这是一个用于测试EL语句的测试语句,如果出现该语句则说明EL表达式使用成功!";
session.setAttribute("information", info);
%>
<input type="text" value="${sessionScope.information }???"> 
</input>
<input value="is name null?  ${empty name}"></input>
<input value="is information null?  ${empty information}"></input>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/qq_37334150/article/details/85216327
EL