벨로시티에서 제공하는 툴들은 여러 종류가 있다.
GenericTools
VelocityView
VelocityStruts
이 있는데... 간단하게 GenericTools 에 있는 DateTool 을 사용해봤다.
http://jakarta.apache.org/velocity/tools/generic/
요기 GenericTools 를 볼 수 있당.
사용법은 무지 간단..
먼저 Tool 을 사용하기 위해.. toolbox.xml 을 WEB-INF/ 디렉토리에 생성하고,
VelocityViewServlet 에 해당 툴을 등록시켜주면 된다.
=============================================
<?xml version="1.0" encoding="UTF-8"?>
<toolbox>
<tool>
<key>date</key>
<scope>application</scope>
<class>org.apache.velocity.tools.generic.DateTool</class>
</tool>
</toolbox>
=============================================
web.xml 에서 VelocityViewServlet 에 init-param 으로 toolbox.xml 을 지정해 주어야 한다.
=============================================
<init-param>
<param-name>org.apache.velocity.toolbox</param-name>
<param-value>/WEB-INF/toolbox.xml</param-value>
</init-param>
=============================================
이렇게 적어주고... 해당 컨텍스트 리로딩..
마지막으로 test.vm 파일에 아래와 같이 적어준당..
=============================================
<BR><HR><BR>
$date.getDate()
<BR>
$date.format('yyyy-MM-dd aaa H:m:s', $date)
<BR>
$date.short || $date.medium || $date.long
<BR>
$date.get('yyyy-M-d H:m:s a')
=============================================
http://localhost:8080/velocity/test.do
오옷... 날짜 나와따~~
이런식으로 제공되는 Tool들을 지정해서 쓰면 된당..
'JAVA > Framework' 카테고리의 다른 글
첨으로 Spring 해바따.. (0) | 2005.02.14 |
---|---|
[펌] Spring Framework Forum (0) | 2005.02.14 |
[울트라 간단 허접]벨로시티에 스트러츠도 함 붙여볼까?? (0) | 2005.02.12 |
[울트라 초 간단] Velocity 시작 ㅡㅡ (0) | 2005.02.12 |
헷갈리 ㅡㅡ;; (0) | 2005.02.12 |