예: tsx:repeat JavaServer Pages 태그를 사용하여 결과 세트 반복(사용되지 않음)

<tsx:repeat> 태그는 결과 세트를 반복합니다. 결과 세트는 Bean 내에 포함되어 있습니다. Bean은 정적 Bean(예: IBM® WebSphere® Studio 데이터베이스 마법사를 사용하여 작성되는 Bean)이거나 동적으로 생성되는 Bean(예: <tsx:dbquery> 구문을 사용하여 생성되는 Bean)일 수 있습니다.

제거된 기능 제거된 기능: JSP(JavaServer Pages) 엔진에서 tsx 태그에 대한 지원은 WebSphere Application Server 버전 6.0에서 더 이상 사용되지 않습니다. tsx 태그를 사용하는 대신, JSTL(JavaServer Pages Standard Tag Library)에서 동일한 태그를 사용해야 합니다. depfeat

다음 표는 myBean이라는 Bean의 컨텐츠를 그래픽으로 표시합니다.

표 1. myBean의 그래픽 표시.. myBean 컨텐츠.
col1 col2 col3
row0 friends Romans countrymen
row1 bacon lettuce tomato
row2 May June July

다음은 Bean에 대한 정보입니다.

다음 표는 <tsx:repeat> 태그를 사용한 정적 Bean 반복을 동적으로 생성되는 Bean에 대해 비교합니다.

표 2. 정적 Bean 및 <tsc:repeat> Bean 예. 두 Bean을 비교하려면 이 표를 사용하십시오.
정적 Bean 예 <tsx:repeat> Bean 예
myBean.class
// Code to get a connection

// Code to get the data
   Select * from myTable;

// Code to close the connection
JSP 파일
<tsx:repeat index=abc>
  <tsx:getProperty name="myBean"
    property="col1(abc)" />
</tsx:repeat>
참고:
  • Bean(myBean.class)은 정적 Bean입니다.
  • Bean 특성에 액세스하는 메소드는 myBean.get(property(index))입니다.
  • 특성 색인을 생략할 수 있으며, 이러한 경우에는 <tsx:repeat> 태그로 묶인 색인이 사용됩니다. 또한 <tsx:repeat> 태그에서 색인을 생략할 수도 있습니다.
  • <tsx:repeat> 태그는 시작 행에서 시작하여 행별로 Bean 특성을 반복합니다.
JSP 파일
<tsx:dbconnect id="conn"
userid="alice"passwd="test"
url="jdbc:db2:sample"
driver="COM.ibm.db2.jdbc.app.DB2Driver">
</tsx:dbconnect >

<tsx:dbquery id="dynamic"
 connection="conn" >
  Select * from myTable;
</tsx:dbquery>

<tsx:repeat index=abc>
  <tsx:getProperty name="dynamic"
    property="col1(abc)" />
</tsx:repeat>
참고:
  • Bean(동적)은 <tsx:dbquery> 태그에 의해 생성되며 구문이 실행될 때까지 존재하지 않습니다.
  • Bean 특성에 액세스하는 메소드는 dynamic.getValue("property", index)입니다.
  • 특성 색인을 생략할 수 있으며, 이러한 경우에는 <tsx:repeat> 태그로 묶인 색인이 사용됩니다. 또한 <tsx:repeat> 태그에서 색인을 생략할 수도 있습니다.
  • <tsx:repeat> 태그 구문은 시작 행에서 시작하여 행별로 Bean 특성을 반복합니다.

내재적(implicit) 및 명시적(explicit) 색인 작성

예 1, 2, 3에서는 <tsx:repeat> 태그의 사용법을 보여줍니다. 모든 색인화된 특성이 300개 이하의 요소를 가지면 예에서 동일한 출력을 생성합니다. 300개보다 많은 요소가 있는 경우, 예 1, 2에서는 모든 요소를 표시하는 반면 예 3에서는 처음 300개의 요소만을 표시합니다.

예 1에서는 기본 시작 색인 및 종료 색인이 있는 내재적 색인을 보여줍니다. 색인화된 특성 수가 가장 적은 Bean은 루프 반복 수를 제한합니다.

<table>
<tsx:repeat>
  <tr><td><tsx:getProperty name="serviceLocationsQuery" property="city" />
  </tr></td>
  <tr><td><tsx:getProperty name="serviceLocationsQuery" property="address" />
  </tr></td>
  <tr><td><tsx:getProperty name="serviceLocationsQuery" property="telephone" />
  </tr></td>
</tsx:repeat>
</table>

예 2에서는 색인화, 시작 색인 및 종료 색인을 보여줍니다.

<table>
<tsx:repeat index=myIndex start=0 end=2147483647>
  <tr><td><tsx:getProperty name="serviceLocationsQuery" property=city(myIndex) />
  </tr></td>
  <tr><td><tsx:getProperty name="serviceLocationsQuery" property=address(myIndex) />
  </tr></td>
  <tr><td><tsx:getProperty name="serviceLocationsQuery" property=telephone(myIndex) />
</tr></td>
</tsx:repeat>
</table>

예 3에서는 명시적 색인화 및 내재적 시작 색인을 가진 종료 색인을 보여줍니다. 색인 속성이 지정되더라도 (myIndex) 태그가 필수가 아니므로 색인화된 특성 city를 여전히 내재적으로 색인화될 수 있습니다.

<table>
<tsx:repeat index=myIndex end=299>
  <tr><td><tsx:getProperty name="serviceLocationsQuery" property="city" /t>
  </tr></td>
  <tr><td><tsx:getProperty name="serviceLocationsQuery" property="address(myIndex)" />
  </tr></td>
  <tr><td><tsx:getProperty name="serviceLocationsQuery" property="telephone(myIndex)" />
  </tr></td>
</tsx:repeat>
</table>

<tsx:repeat> 블록 중첩

<tsx:repeat> 블록을 중첩시킬 수 있습니다. 각 블록은 별도로 색인화됩니다. 이 기능은 두 개의 Bean의 인터리빙 특성 또는 부속 특성을 가진 특성에 유용합니다. 예에서는 두 <tsx:repeat> 블록이 중첩되어 사용자 장바구니에 있는 각 컴팩트 디스크의 노래 목록을 표시합니다.

<tsx:repeat index=cdindex>
  <h1><tsx:getProperty name="shoppingCart" property=cds.title /></h1>
  <table>
  <tsx:repeat>
    <tr><td><tsx:getProperty name="shoppingCart" property=cds(cdindex).playlist />
    </td></tr>
  </tsx:repeat>
  </table>
 </tsx:repeat>

주제 유형을 표시하는 아이콘 참조 주제



시간소인 아이콘 마지막 업데이트 날짜: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=rweb_jrepr
파일 이름:rweb_jrepr.html