웹/JSP
EL태그 / 표현언어(EL, Expression Lnaguage)/eq,ne,lt,le,gt,ge
은은하게미친자
2022. 7. 19. 11:24
728x90
request.setAttribute("name","aaa"); => request 내장객체에 name 속성으로 aaa저장 ${name} => EL문법 표현식 출력 : aaa => jsp 페이지 출력 결과. |
* 표현언어 기본 내장객체
내장객체 | 설명 |
pageScope | page 영역에 존재하는 객체를 참조할때 사용 |
requestScope | request영역에 존재하는 객체를 참조할때 |
sessionScope | session 영역에존재하는 객체 참조 할때 |
applicationScope | application 영역에 존재하는 객체를 잠조할때 |
param | 파라미터 값을 얻어올때 |
paramValues | 파라미터 값을 배열로 얻어올 때 |
header | 헤더정보를 얻어올때 |
headerValues | 헤더정보를 배열로 얻어올 때 |
cookie | 쿠키객체를참조할때 |
initParam | 컨텍스트의 초기화 파라미터를 의미 |
pageContext | pageContext 객체를 참조할때 |
* EL의 내장객체 표현문법
문법 | 설명 |
${param.id} | 하나의 요청 값일때 |
${param["id"]} | |
${paramValues.study[0]} | 다수개의 요청값일때 |
${paramValues.["study"][1]} |
* el 태그 에서 비교 연산자
== | eq | equal | 같은경우 |
!= | ne | not equal | 다른경우 |
< | lt | little | 작은경우 |
> | gt | little or equal | 작거나 같은경우 |
<= | le | greater | 큰경우 |
>= | ge | greater or equal | 크거나 같은 경우 |
empty : 값이 null일경우 true 반환
<%@ page isELIgnored="true"%> <!-- true면 EL문법 무시 -->
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ page isELIgnored="false"%> <!-- true면 EL문법 무시 -->
<%
request.setAttribute("siteName", "java");
pageContext.setAttribute("msg", "꿈은이루어진당");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>EL</title>
</head>
<body>
${siteName}
<%
int sum=0;
for(int i=1;i<11;i++){
sum += i;
}
request.setAttribute("sum", new Integer(sum));
%>
<%
request.getAttribute("sum");
request.setCharacterEncoding("utf-8");
%>
<br>
${pageScope.msg} <br>
${requestScope.sum}<br>
<form action="practice_el_01_1.jsp" method="post">
send param1 : <input name="param1"></br>
send param2 : <input name="param2"></br>
check1 : <input type="checkbox" name="optionCheck" value="value1">
check2 : <input type="checkbox" name="optionCheck" value="value2">
check3 : <input type="checkbox" name="optionCheck" value="value3">
check4 : <input type="checkbox" name="optionCheck" value="value4">
check5 : <input type="checkbox" name="optionCheck" value="value5">
<input type="submit" value="send">
</form>
<h2>EL의 내장객체</h2>
호스트명 : ${header.host}</br>
사용브라우저 : ${header["user-agent"]}</br>
사용언어 : ${header["accept-language"]}</br>
</body>
</html>
|
cs |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%request.setCharacterEncoding("utf-8"); %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
param1 : ${param.param1} <br/>
param2: ${param.param2} <br/>
checkbox:
${paramValues.optionCheck[0]}
${paramValues.optionCheck[1]}
${paramValues.optionCheck[2]}
${paramValues.optionCheck[3]}
${paramValues.optionCheck[4]}
</body>
</html>
|
cs |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%
ArrayList<String[]> list = new ArrayList<String[]>();
String arr[]={"arr1","arr2","arr3","arr4","arr5","arr6"};
for(int i=0;i<5;i++){
list.add(arr);
pageContext.setAttribute("list", list);
}
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ArrayList</title>
</head>
<body>
${list[0]}<br>
${list[1]}<br>
${list[2]}<br>
${list[3]}<br>
${list[4]}<br>
${list[0][0]}<br>
${list[0][1]}<br>
${list[0][2]}<br>
${list[0][3]}<br>
${list[0][4]}<br>
${list[1][0]}<br>
${list[2][1]}<br>
${list[3][2]}<br>
${list[4][3]}<br>
${list[5][4]}<br>
</body>
</html> =
|
cs |
728x90