권형&오형의 일상
[권형] Spring tiles 설정(maven, spring3) 본문
pom.xml
1 2 3 4 | <properties> (중략) <org.apache.tiles.version>3.0.7</org.apache.tiles.version> </properties> |
3 버전 안에서 알아서 쓰면됨.
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 | <dependencies> (중략) <!-- tiles --> <dependency><!-- https://mvnrepository.com/artifact/org.apache.tiles/tiles-servlet --> <groupId>org.apache.tiles</groupId> <artifactId>tiles-servlet</artifactId> <version>${org.apache.tiles.version}</version> </dependency> <dependency><!-- https://mvnrepository.com/artifact/org.apache.tiles/tiles-extras --> <groupId>org.apache.tiles</groupId> <artifactId>tiles-extras</artifactId> <version>${org.apache.tiles.version}</version> </dependency> <dependency><!-- https://mvnrepository.com/artifact/org.apache.tiles/tiles-jsp --> <groupId>org.apache.tiles</groupId> <artifactId>tiles-jsp</artifactId> <version>${org.apache.tiles.version}</version> </dependency> <dependency><!-- https://mvnrepository.com/artifact/org.apache.tiles/tiles-jsp --> <groupId>org.apache.tiles</groupId> <artifactId>tiles-core</artifactId> <version>${org.apache.tiles.version}</version> </dependency> </dependencies> |
root-context.xml
1 2 3 4 5 6 7 8 | <beans (중략)> (중략) <!-- tiles3 --> <bean class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView" /> <property name="order" value="2" /> </bean> </beans> |
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 | <?xml version="1.0" encoding="UTF-8"?> <beans:beans (중략)> (중략) <!-- Tiles configuration --> <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> <!-- 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="order" value="2" /> <beans:property name="prefix" value="/WEB-INF/views/" /> <beans:property name="suffix" value=".jsp" /> </beans:bean> <beans:bean id="jsonView" class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" /> </beans:beans> |
tiles/tiles.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN" <tiles-definitions> <definition name="layout" template="/WEB-INF/tiles/layout/layout.jsp"> <put-attribute name="header" value="/WEB-INF/tiles/tile/header.jsp"/> <put-attribute name="leftMenu" value="/WEB-INF/tiles/tile/leftMenu.jsp"/> <put-attribute name="footer" value="/WEB-INF/tiles/tile/footer.jsp"/> </definition> <definition name="/*/*" extends="layout"> <put-attribute name="content" value="/WEB-INF/views/{1}/{2}.jsp" /> </definition> </tiles-definitions> |
tiles/layout/layout.jsp
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 | <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN" <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body class="hold-transition skin-blue sidebar-mini"> <div id="wrapper"> <div id="header"> <tiles:insertAttribute name="header" /> </div> <div id="leftMenu"> <tiles:insertAttribute name="leftMenu" /> </div> <div id="content"> <tiles:insertAttribute name="content" /> </div> <div id="footer"> <tiles:insertAttribute name="footer" /> </div> </div> </body> </html> <!-- jQuery 2.2.3 --> <script src="/assets/js/jquery-2.2.3.min.js"></script> |
tiles/tile/footer.jsp
tiles/tile/header.jsp
tiles/tile/leftMenu.jsp
tiles/tile/meta.jsp
설정 메모한거라 성의가없습니다. 죄송합니다.
'개발 > Spring' 카테고리의 다른 글
[권형] @ResponseBody + @RequestBody 추가 설정 (0) | 2017.09.26 |
---|
Comments