EL语言的目的:
用于无java代码的JSP页面
创建el1.jsp,el2.jsp
el1.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
<%@ 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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
<%@ 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/p/7710422.html,如需转载请自行联系原作者