본문 바로가기
Study/SPRING FRAMEWORK

jsp 에서 변수 전달 (통신)

by Answer Choi 2015. 2. 12.
반응형




변수 전달 방법에 2가지 정도의 방법이 있습니다. 

 

첫번째는 form 태그를 이용한 방법.

 

두번째는 window.open을 이용한 방법

 

첫번째 방법은 회원가입과 같은 많은정보를 전달하기에 좋은 방법인거 같습니다.

 

예를 들면 회원 가입의 경우입니다.

 

 

이와 같이 회원가입 양식이 있을경우 변수가 많습니다.


그럴때는 아래와 같이 form으로 다 묶어 버립니다.


그리고 하나의 테이블에는 하나의 form밖에 쓰질 못하니~

 

 

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
58
59
60
61
<table align="center" border="1" width="80px" >
<form  name="registForm" action="registProc.do" method="post">
<tr>
    <td height="30" width="20%" bgcolor="#dddddd" align="center">
    <p>ID</p>
    </td>
    <td >              
        <input type="text" readonly="readonly" name="id"/>
        <input type="button" value="중복확인" onclick="idChk()"/>
    </td>
</tr>
 
<tr>
    <td height="30" bgcolor="#dddddd" align="center">
        <p>PASSWORD</p>
    </td>
    <td>
        <input type="password" size="40" maxLength="8" name="pw"/>
    </td>  
</tr>
<tr>
    <td height="30" bgcolor="#dddddd" align="center">
        <p>PASSWORD 확인</p>
    </td>
    <td>
        <input type="password" size="40" maxLength="8" name="pw2"/>
    </td>  
</tr>
<tr>
    <td height="30" bgcolor="#dddddd" align="center">
        <p>SMART PLUG MAC</p>
    </td>
    <td>
        <input type="text" size="40"  maxLength="12" name="mac"/>
    </td>  
</tr>
<tr>
    <td height="30" bgcolor="#dddddd" align="center">
        <p>plug 이름</p>
    </td>
    <td>
        <input type="text" size="40" maxLength="12" name="nick"/>
    </td>  
</tr>
<tr>
    <td height="30" bgcolor="#dddddd" align="center">
        <p>e-mail</p>
    </td>
    <td>
        <input type="email" size="40" maxLength="20" name="email"/>
       
    </td>  
</tr>
<tr>
    <td colspan="2" align="center">
        <input type="button" value="가입하기" onclick="chkSumit()"/>
    </td>
   
</tr>
</form>
</table>
cs

 

이런식으로 해서 각 각의 변수를 전달합니다.

 

하지만 정보 조회의 경우에는 이게 먼지 하나의 변수만 보내도 됩니다.

 

이럴때는 window.open이 더 편합니다.

 

아래와 같이 조회를 할경우

 

 

 

이런식으로 javascript를~

 

1
2
3
var url ='customView.do?index=' + index;
             
            window.open(url, '',  '');
cs


요런식으로 해서 변수를 전달합니다.

 

window.open 메소드에 대한 옵션정보는 w3schools에서 확인하세요.

 

반응형

인기글