標籤:blog scope 語言 res log img att charset attribute
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運算式語言)