EL簡用
阿新 • • 發佈:2018-12-23
概述:
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>