반응형
Introduction
JSTL1 태그를 만들어 사용할 때에 스프링 빈을 가져다 쓰는 방법이다.
Using Spring Beans
너무나도 간단하다.
일반적으로 TagSupport 클래스를 상속 받아서 구현 하면 되는데, 스프링 빈을 사용하고 싶으면 RequestContextAwareTag 클래스를 상속 받아서 구현하면 된다.
사용법은 아래와 같다.
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.tags.RequestContextAwareTag;
public class XXXTag extends RequestContextAwareTag {
@Override
protected int doStartTagInternal() throws Exception {
// WebApplicationContext 를 얻는다.
WebApplicationContext ctx = getRequestContext().getWebApplicationContext();
// 빈을 가져와서 처리
return SKIP_BODY;
}
}
Example Source
WAR 파일 (소스 포함)
프로젝트 파일 (메이븐 구조)
- 자바 서버 페이지 표준 태그 라이브러리(JavaServer Pages Standard Tag Library, 약칭 JSTL)은 Java EE 기반의 웹 애플리케이션 개발 플랫폼을 위한 컴포넌트 모음이다. [본문으로]
반응형
'Java+ > Example' 카테고리의 다른 글
| LOGBack Configurator with JMX (0) | 2014.07.20 |
|---|---|
| 현지어로 언어명 보여주기 (0) | 2014.02.09 |
| 2014년 도로명 주소 사용에 따른 우편번호 준비 (2) | 2013.12.22 |
| Spring Message Source from Database (1) | 2013.03.03 |
| Infinite Routing DataSource (1) | 2013.01.13 |
| Mybatis Type Handler (1) | 2012.09.30 |
| Using AUTO_INCREMENT keys (0) | 2011.03.01 |
webapp.war
webapp.zip