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 | 31 |
Tags
- JSP
- layout
- 예외처리
- 이클립스
- 전화걸기
- 클래스
- 안드로이드
- OGNL
- 배열
- Menu
- 메소드
- struts2
- Java
- 국제화
- 어노테이션
- 에러페이지
- mybatis
- oracle
- Eclips
- Android
- AWT
- 오버로딩
- HTML
- 생성자
- Graphic
- paint
- Spring
- JavaScript
- 기본
- 메서드
Archives
- Today
- Total
note
struts2 OGNL 표기 Append / Merge / Date 본문
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="ch7" namespace="/ch7" extends="struts-default">
<!-- 와일드 카드 매핑사용 -->
<action name="*" class="com.ch7.action.{1}Action">
<interceptor-ref name="params" />
<result name="success">/ch7/{1}.jsp</result>
</action>
</package>
</struts>
AppendAction.java / MergeAction.java
package com.ch7.action;
import java.util.ArrayList;
import java.util.List;
import com.opensymphony.xwork2.Action;
public class AppendAction implements Action{
List<String> myList1;
List<String> myList2;
@Override
public String execute() throws Exception {
myList1 = new ArrayList<String>();
myList1.add("a");
myList1.add("b");
myList2 = new ArrayList<String>();
myList2.add("1");
myList2.add("2");
return SUCCESS;
}
public List<String> getMyList1() {
return myList1;
}
public List<String> getMyList2() {
return myList2;
}
}
Append.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>Append Test</title>
</head>
<body>
<h3>append Test</h3>
<s:append id="appendList">
<s:param value="%{myList1}"/>
<s:param value="%{myList2}"/>
</s:append>
<p>${appendList}</p>
<!-- EL표기법 forEach와 같다 변수지정을 안했기에 property도 그냥 쓰면 뽑아냄 -->
<s:iterator value="%{appendList}">
<s:property />
<br/>
</s:iterator>
</body>
</html>
Merge.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>Merge Test</title>
</head>
<body>
<h3>Merge Test</h3>
<s:merge id="mergeList">
<s:param value="%{myList1}" />
<s:param value="%{myList2}" />
</s:merge>
<p>${mergeList}</p>
<s:iterator value="%{mergeList}">
<s:property/>
<br/>
</s:iterator>
</body>
</html>
Date 날짜
DateAction.java
package com.ch7.action;
import java.util.Date;
import com.opensymphony.xwork2.Action;
public class DateAction implements Action{
private Date now;
@Override
public String execute() throws Exception {
now = new Date();
return SUCCESS;
}
public Date getNow() {
return now;
}
}
Date.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>Date Test</title>
</head>
<body>
<s:date name="now" format="yyyy년MM월dd일E요일 a hh:mm:ss"/>
</body>
</html>
SimpleDateFormat과 같다
'JSP > Struts2' 카테고리의 다른 글
| struts2 국제화 (0) | 2012.02.23 |
|---|---|
| struts2 itertator (0) | 2012.02.23 |
| struts2 if / else if / else 태그 예제(OGNL표현식) EL / OGNL 차이점 (0) | 2012.02.23 |
| struts2 업로드파일 다운로드 하기 (0) | 2012.02.23 |
| struts2 예외발생 에러페이지 (0) | 2012.02.22 |