본문 바로가기
IT/JSP

[JSP] EL 연습 01

by dya0 2019. 5. 20.

 

 

화면

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
<%--데이터 입력없이 submit 눌러보기 
    파라미터의 값이 없는 경우 출력되지 않는다. --%>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
    <%request.setCharacterEncoding("euc-kr"); %>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>EL 파라미터 연습</title>
<style type="text/css">
body, form {
    margin: 0 auto;
    text-align: center;
}
 
table {margin: 0 auto;
    background: yellow;
    text-align: center;
}
 
tr {
    background: yellow;
}
 
tr:nth-child(2) {
    background: green;
}
</style>
</head>
<body>
<form action = "el_result.jsp" method = "post">
<table>
<tr>
<td>이름 </td>
<td><input type = "text" name = "name"></td>
</tr>
<tr>
<td>취미</td>
<td>
<input type="checkbox" name = "hobby" value= "독서"><span>독서</span>
<input type="checkbox" name = "hobby" value= "놀기"><span>놀기</span>
</td>
</tr>
</table>
<input type = "submit" value = "입력">
</form>
 
</body>
</html>
 

아무것도 안 보내면 값이 화면에 나오지 않음 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
    <%request.setCharacterEncoding("euc-kr"); %>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
<h3>넘어온 이름은 : ${param.name}</h3>
<h3>넘어온 취미는 : ${paramValues.hobby[0]}, 
</body>
</html>
Colored by Color Scripter

'IT > JSP' 카테고리의 다른 글

[JSP] EL 자바빈 사용  (0) 2019.05.20
[JSP] EL연습 02  (0) 2019.05.20
[JSP] JSTL  (0) 2019.05.20
[JSP] 커넥션 풀을 이용한 페이지 제어 연습 02  (0) 2019.05.16
[JSP] 서블릿 생명주기  (0) 2019.05.16