JSP中的EL (Express Language表達式語言)
阿新 • • 發佈:2017-10-22
odi highlight htm 分享 nco value brush tty con
EL語言的目的:
用於無java代碼的JSP頁面
創建el1.jsp,el2.jsp
el1.jsp
<%@ 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> <form action="el2.jsp"> username: <input type="text" name="username"> <input type="submit" value="submit"> </form> <% session.setAttribute("hello", "world"); %> </body> </html>
el2.jsp
<%@ 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> <%= request.getParameter("username") %><br> el表達式: ${param.username} <br> <%= session.getAttribute("hello") %><br> el表達式: ${sessionScope.hello} </body> </html>
效果圖
JSP中的EL (Express Language表達式語言)