Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 예외처리
- JavaScript
- Menu
- Graphic
- 기본
- 생성자
- JSP
- mybatis
- 이클립스
- 배열
- layout
- 클래스
- 어노테이션
- 메소드
- 국제화
- HTML
- 안드로이드
- 전화걸기
- OGNL
- oracle
- Eclips
- struts2
- 오버로딩
- AWT
- paint
- 에러페이지
- 메서드
- Android
- Java
- Spring
Archives
- Today
- Total
note
struts2 itertator 본문
com.ch7.domain/Board.java
package com.ch7.domain;
public class Board {
private int no;
private String subject;
private String name;
private String content;
public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
IteratorAction.java
package com.ch7.action;
import java.util.ArrayList;
import java.util.List;
import com.ch7.domain.Board;
import com.opensymphony.xwork2.Action;
public class IteratorAction implements Action{
private List<Board>list;
@Override
public String execute() throws Exception {
list = new ArrayList<Board>();
Board board = new Board();
board.setNo(1);
board.setSubject("첫 방문");
board.setName("우허허");
board.setContent("게시판 오픈 ㅊㅋ");
list.add(board);
Board board2 = new Board();
board2.setNo(2);
board2.setSubject("송년회");
board2.setName("개구리");
board2.setContent("잡담");
list.add(board2);
Board board3 = new Board();
board3.setNo(3);
board3.setSubject("졸업작품");
board3.setName("팥쥐");
board3.setContent("월드컵과 올림픽을 형상화");
list.add(board3);
return SUCCESS;
}
public List<Board> getList() {
return list;
}
}
Iterator.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!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>iterator Test</title>
</head>
<body>
<table border="1" cellspacing="0" cellpadding="1" width="100%" align="center">
<tr>
<td>번호</td>
<td>제목</td>
<td>글쓴이</td>
<td>내용</td>
</tr>
<s:iterator value="list">
<tr>
<td><s:property value="no" /></td>
<td><s:property value="subject" /></td>
<td><s:property value="name" /></td>
<td><s:property value="content" /></td>
</tr>
</s:iterator>
</table>
</body>
</html>
오히려 EL표기법 foreach보다 편하다
[JSP/JSTL] - EL , JSTL 코어태그 (c:forEach)(c:choose)
'JSP > Struts2' 카테고리의 다른 글
| struts2 <s:set /> (0) | 2012.02.23 |
|---|---|
| struts2 국제화 (0) | 2012.02.23 |
| struts2 OGNL 표기 Append / Merge / Date (0) | 2012.02.23 |
| struts2 if / else if / else 태그 예제(OGNL표현식) EL / OGNL 차이점 (0) | 2012.02.23 |
| struts2 업로드파일 다운로드 하기 (0) | 2012.02.23 |