반응형
Tiles 사용법
Tiles 란?
: View 에서 레이아웃을 구성할 때 , 공통적인 부분(include 등)을 쉽게 적용하기 위한 템플릿 프레임워크
장점
: include 디자인을 변경하면 페이지를 전체적으로 수정해야하는 번거러옴울 없앰
일관적인 페이지 관리를 가능함
Tiles Framework의 공식 사이트
https://tiles.apache.org/
사용조건
tiles 3.08 버전 기준
1. JSTL 라이브러리
2. JDK 1.7 이상
3. Servlet 2.5 이상
4. Spirng 3.2 이상
사용방법
1. Pom.xml 설정
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <!-- tiles3 --> <dependency> <groupId>org.apache.tiles</groupId> <artifactId>tiles-extras</artifactId> <version>3.0.8</version> </dependency> <dependency> <groupId>org.apache.tiles</groupId> <artifactId>tiles-servlet</artifactId> <version>3.0.8</version> </dependency> <dependency> <groupId>org.apache.tiles</groupId> <artifactId>tiles-jsp</artifactId> <version>3.0.8</version> </dependency> | cs |
2. servlet-context.xml 설정
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 32 33 34 35 36 37 38 39 | <?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure --> <!-- Enables the Spring MVC @Controller programming model --> <annotation-driven /> <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory --> <resources mapping="/resources/**" location="/resources/" /> <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory --> <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <beans:property name="prefix" value="/WEB-INF/views/" /> <beans:property name="suffix" value=".jsp" /> <beans:property name="order" value="2" /> </beans:bean> <context:component-scan base-package="com.tiles.tiles" /> <!-- Tiles --> <beans:bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <beans:property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView" /> <beans:property name="order" value="1" /> </beans:bean> <beans:bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"> <beans:property name="definitions"> <beans:list> <beans:value>/WEB-INF/tiles/tiles.xml</beans:value> </beans:list> </beans:property> </beans:bean> </beans:beans> | cs |
기존 servle-contextxml에 Tiles설정을 추가한다.
* 주의할점은 기존 ViewResolver의 order 우선순위를 tilesViewResolver보다 늦춰야한다.
* 만약 tilesConfigurer에 에러가 난다면, 라이브러리와 tiles3의 최소 사용조건을 확인해야함.
3. /WEB-INF/tiles/tiles.xml
반응형
'Backend FrameWork > Spring' 카테고리의 다른 글
[SpringFramework] Spring Scheduling - Task (0) | 2019.02.04 |
---|---|
[SpringFrameWork] Google SMPT 사용법 (0) | 2019.01.22 |
[SpringFrameWork] Spring Security - Bcrypt (0) | 2019.01.17 |
[SpringFramework] slf4j, Logback 사용 (0) | 2019.01.01 |
[Spring Framework] Spring MVC : @RequestMapping 개념 (0) | 2018.12.28 |