tiles3의 경우 스프링 3.2.0 이상 버전을 요구합니다. 3.2.0 미만의 버전을 사용하시는 분은 tiles2를 사용하시면 됩니다.
저의 경우, 하단과 같이 스프링 3.1.1 버전이라 tiles2를 사용했습니다.
== pom.xml ==
<properties>
<java-version>1.6</java-version>
<org.springframework-version>3.1.1.RELEASE</org.springframework-version>
<org.aspectj-version>1.6.10</org.aspectj-version>
<org.slf4j-version>1.6.6</org.slf4j-version>
<org.apache.tiles-version>2.2.2</org.apache.tiles-version> <== 추가
</properties>
...
...
<!-- Tiles -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-extras</artifactId>
<version>${org.apache.tiles-version}</version>
</dependency> <== 추가
끝
========================================================================
== /WEB-INF/spring/appServlet/servlet-context.xml ==
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
위 소스를 삭제한 뒤,
<beans:bean id="tilesViewResolver"
class="org.springframework.web.servlet.view.tiles2.TilesViewResolver" />
<beans:bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<beans:property name="definitions" value="/WEB-INF/tiles-defs.xml" />
</beans:bean>
위 소스로 입력
끝
========================================================================
== /WEB-INF/tiles-defs.xml ==
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
"http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
<tiles-definitions>
<definition name=".main" template="/WEB-INF/views/layouts/layout.jsp">
<put-attribute name="header" value="/WEB-INF/views/layouts/header.jsp" />
<put-attribute name="main" value="/WEB-INF/views/layouts/main.jsp" />
<put-attribute name="footer" value="/WEB-INF/views/layouts/footer.jsp" />
</definition>
<definition name="home" extends=".main">
<put-attribute name="main" value="/WEB-INF/views/home.jsp" />
</definition>
</tiles-definitions>
xml파일 생성 후, 입력
끝
========================================================================
== /WEB-INF/views 위치에 하단이미지처럼 폴더 및 파일 생성
끝
========================================================================
최종 화면
댓글