14.3. Tiles
14.3.1. Dependencies
Tiles를 사용하려면 다음의 jar파일들이 필요합니다.
- Struts version 1.1 or highe
- Commons BeanUtils
- Commons Digester
- Commons Lang
- Commons Logging
14.3.2. How to integrate Tiles
Tile를 사용할 때 필요한 definition 파일들을 서술해 줍니다.
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles.TilesConfigurer">
<property name="factoryClass" value="org.apache.struts.tiles.xmlDefinition.I18nFactorySet"/>
<property name="definitions">
<list>
<value>/WEB-INF/defs/general.xml</value>
<value>/WEB-INF/defs/widgets.xml</value>
<value>/WEB-INF/defs/administrator.xml</value>
<value>/WEB-INF/defs/customer.xml</value>
<value>/WEB-INF/defs/templates.xml</value>
</list>
</property>
</bean>
<property name="factoryClass" value="org.apache.struts.tiles.xmlDefinition.I18nFactorySet"/>
<property name="definitions">
<list>
<value>/WEB-INF/defs/general.xml</value>
<value>/WEB-INF/defs/widgets.xml</value>
<value>/WEB-INF/defs/administrator.xml</value>
<value>/WEB-INF/defs/customer.xml</value>
<value>/WEB-INF/defs/templates.xml</value>
</list>
</property>
</bean>
위 설정에서 다섯개의 definition들을 세팅했습니다. 저 파일들이 각각 하나의 tile인건가요? 흠;; 안써봐서 모르겠군요;
Anyway, Tiles도 사용하려면 역시 ViewResolver를 등록해야 하는데 역시 두 가지 Resolver를 사용할 수 있습니다.
- InternalResourceViewResolver
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="requestContextAttribute" value="requestContext"/>
<property name="viewClass" value="org.springframework.web.servlet.view.tiles.TilesView"/>
</bean>
<property name="requestContextAttribute" value="requestContext"/>
<property name="viewClass" value="org.springframework.web.servlet.view.tiles.TilesView"/>
</bean>
- ResourceBundleViewResolver
<bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
<property name="basename" value="views"/>
</bean>
<property name="basename" value="views"/>
</bean>
...
welcomeView.class=org.springframework.web.servlet.view.tiles.TilesView
welcomeView.url=welcome (<b>this is the name of a definition</b>)
welcomeView.class=org.springframework.web.servlet.view.tiles.TilesView
welcomeView.url=welcome (<b>this is the name of a definition</b>)
vetsView.class=org.springframework.web.servlet.view.tiles.TilesView
vetsView.url=vetsView (again, this is the name of a definition)
findOwnersForm.class=org.springframework.web.servlet.view.JstlView
findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp
...
여기서 볼 수 있듯이 ResourceBundleViewResolver 를 사용하면 여러 view 기술을 혼용할 수 있습니다.