<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ page import="com.lzp.domain.*" %> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>My JSP 'el.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <c:out value="el表达式测试"></c:out> <% request.setAttribute("username", "requestusername"); session.setAttribute("username", "sessionusername"); pageContext.setAttribute("username", "pageContextusername"); application.setAttribute("username", "applicationusername"); %> <c:out value="全域查找结果"/> ${username } <br/> ${pageScope.username}<br/> ${applicationScope.username }<br/> ${sessionScope.username}<br/> ${requestScope.username}<br/> <h6>javaBean与el相结合的使用</h6> <% Person p =new Person(); p.setAge(22); p.setName("王小明"); request.setAttribute("p", p); %> ${p.age }${p.name } <h6>其他对象</h6> ${param.XXX } ${paramValues.YYY[0] } ${paramValues.YYY[1] } ${cookie.JSESSIONID.value}=${cookie.JSESSIONID.name} ${pageContext.request.contextPath } ${fn:length(paramValues)} ${fn:toLowerCase(param.XXX)} </body> </html>
http://localhost:8090/jstl/el.jsp?XXX=AAA&YYY=yyy&YYY=yyy1