JSP中的EL (Express Language表达式语言)
Posted on 2017-10-22 16:08 work hard work smart 阅读(333) 评论(0) 编辑 收藏 举报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>
效果图
作者:Work Hard Work Smart
出处:http://www.cnblogs.com/linlf03/
欢迎任何形式的转载,未经作者同意,请保留此段声明!