728x90
타일즈 라이브러리 설정하기
@Configuration이 있는 파일을 만들고, pom.xml 파일에 tiles-jsp dependency를 추가하면 된다.
특히 tiles.xml의 value="경로"를 잘 지정해주도록 한다.
tiles-jsp dependency 추가 방법 :
pom.xml > Dependencies > Add... > tiles-jsp 선택 및 추가
@Configuration
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
|
package com.address.web.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.view.UrlBasedViewResolver;
import org.springframework.web.servlet.view.tiles3.SimpleSpringPreparerFactory;
import org.springframework.web.servlet.view.tiles3.TilesConfigurer;
import org.springframework.web.servlet.view.tiles3.TilesView;
import org.springframework.web.servlet.view.tiles3.TilesViewResolver;
@Configuration
public class TilesConfig {
@Bean
public TilesConfigurer tilesConfigurer() {
TilesConfigurer tilesConfigurer = new TilesConfigurer();
tilesConfigurer.setDefinitions(new String[] {"/WEB-INF/tiles.xml"});
tilesConfigurer.setCheckRefresh(true);
tilesConfigurer.setPreparerFactoryClass(SimpleSpringPreparerFactory.class);
return tilesConfigurer;
}
@Bean
public TilesViewResolver tilesViewResolver() {
TilesViewResolver viewResolver = new TilesViewResolver();
viewResolver.setViewClass(TilesView.class);
viewResolver.setOrder(1);
return viewResolver;
}
@Bean
public UrlBasedViewResolver viewResolver() {
final UrlBasedViewResolver resolver = new UrlBasedViewResolver();
resolver.setViewClass(TilesView.class);
resolver.setOrder(1);
return resolver;
}
}
|
cs |
tiles.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
40
41
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
"http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
<tiles-definitions>
<definition name="root.*" template="/WEB-INF/view/inc/layout.jsp">
<put-attribute name="css" value="" />
<put-attribute name="header" value="/WEB-INF/view/inc/header.jsp" />
<put-attribute name="aside" value="/WEB-INF/view/inc/aside.jsp" />
<put-attribute name="main" value="/WEB-INF/view/{1}.jsp" />
<put-attribute name="footer" value="/WEB-INF/view/inc/footer.jsp" />
</definition>
<definition name="admin.*.*.*" template="/WEB-INF/view/inc/layout.jsp">
<put-attribute name="css" value="" />
<put-attribute name="header" value="/WEB-INF/view/inc/header.jsp" />
<put-attribute name="aside" value="/WEB-INF/view/admin/inc/aside.jsp" />
<put-attribute name="main" value="/WEB-INF/view/admin/{1}/{2}/{3}.jsp" />
<put-attribute name="footer" value="/WEB-INF/view/inc/footer.jsp" />
</definition>
<definition name="admin.*" template="/WEB-INF/view/inc/layout.jsp">
<put-attribute name="css" value="" />
<put-attribute name="header" value="/WEB-INF/view/inc/header.jsp" />
<put-attribute name="aside" value="/WEB-INF/view/admin/inc/aside.jsp" />
<put-attribute name="main" value="/WEB-INF/view/admin/{1}.jsp" />
<put-attribute name="footer" value="/WEB-INF/view/inc/footer.jsp" />
</definition>
<definition name="member.*" template="/WEB-INF/view/inc/layout.jsp">
<put-attribute name="css" value="/css/member-main.css" />
<put-attribute name="header" value="/WEB-INF/view/inc/header.jsp" />
<put-attribute name="aside" value="/WEB-INF/view/member/inc/aside.jsp" />
<put-attribute name="main" value="/WEB-INF/view/member/{1}.jsp" />
<put-attribute name="footer" value="/WEB-INF/view/inc/footer.jsp" />
</definition>
<definition name="notice.*" template="/WEB-INF/view/inc/layout.jsp">
<put-attribute name="css" value="" />
<put-attribute name="header" value="/WEB-INF/view/inc/header.jsp" />
<put-attribute name="aside" value="/WEB-INF/view/inc/aside.jsp" />
<put-attribute name="main" value="/WEB-INF/view/notice/{1}.jsp" />
<put-attribute name="footer" value="/WEB-INF/view/inc/footer.jsp" />
</definition>
</tiles-definitions>
|
cs |
반응형
'Web programming > Spring' 카테고리의 다른 글
JDBC와 MyBatis 차이, MyBatis 정의 및 사용 (2) | 2020.06.18 |
---|---|
Maven 사용을 위한 준비 (0) | 2020.06.16 |
Spring Boot 시작 / Spring Tools 4로 프로젝트 생성 (0) | 2020.06.16 |
Maven - Build Lifecycle (0) | 2020.06.16 |
Maven란? Apache Maven 설치 (0) | 2020.06.16 |